Use PowerShell for detailed checks and Command Prompt for fast fallbacks when a Windows PC cannot reach a server, map a shared drive, or resolve a DNS name. Microsoft includes tools such as Test-NetConnection, Resolve-DnsName, net use, and nslookup in Windows, so most checks need no extra software [source: Microsoft].
TLDR: An administrator can check active connections with Get-NetTCPConnection or netstat -ano, map drives with New-PSDrive or net use, and test DNS with Resolve-DnsName or nslookup. For example, if 38 of 50 users cannot open \\fileserver\finance, the admin can test port 445, map the share, and confirm DNS in under five minutes. If DNS is wrong, the fix may be as simple as clearing the local cache with ipconfig /flushdns. PowerShell gives richer output, while Command Prompt is quick and familiar.
Checking active network connections
PowerShell is usually the cleaner choice for finding live connections. It returns objects, not just text. That makes filtering easier and faster.
To list active TCP connections, an administrator can run:
Get-NetTCPConnection
To see only established sessions:
Get-NetTCPConnection -State Established
To check whether a server answers on a specific port, this command is often the fastest:
Test-NetConnection fileserver01 -Port 445
Port 445 matters because Windows file sharing uses SMB. If that port fails, a mapped drive will likely fail too. Honestly, it feels like half of “the drive is gone” tickets start with this one blocked port.
Command Prompt still helps. It is blunt, but reliable:
netstat -ano
This shows local addresses, remote addresses, ports, connection states, and process IDs. If a process looks suspicious, the process ID can be matched in Task Manager. For a quick reachability test, old tools still work:
ping servernamechecks basic response.tracert servernameshows the route traffic takes.pathping servernamemixes route and packet loss checks.
Mapping network drives with PowerShell
PowerShell can map a drive with New-PSDrive. For a temporary drive mapping, the command looks like this:
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\fileserver01\finance"
For a persistent mapping that survives sign out and restart, this version is better:
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\fileserver01\finance" -Persist
If different credentials are needed, the admin can collect them first:
$cred = Get-Credential
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\fileserver01\finance" -Credential $cred -Persist
To remove the drive later:
Remove-PSDrive -Name Z
The catch is that -Persist can act strangely if PowerShell is started as administrator. The mapped drive may appear in the admin session but not in the user’s File Explorer. That wastes time and makes the fix look broken. Running the command in the user’s normal session avoids that headache.
Mapping drives with Command Prompt
Command Prompt uses net use. It is simple and still widely used in login scripts.
net use Z: \\fileserver01\finance
To make it persistent:
net use Z: \\fileserver01\finance /persistent:yes
To map with a specific user account:
net use Z: \\fileserver01\finance /user:DOMAIN\j.smith *
The asterisk prompts for a password without showing it on screen. To delete the mapping:
net use Z: /delete
To list current mapped drives:
net use
Diagnosing DNS issues
DNS problems can look like network failures. A user may say the server is down, but the PC may simply be resolving the wrong address.
PowerShell offers Resolve-DnsName:
Resolve-DnsName fileserver01
To query a specific DNS server:
Resolve-DnsName fileserver01 -Server 10.0.0.10
This helps compare results. If the local DNS server returns one IP address and another DNS server returns a different one, the record may be stale.
Command Prompt uses nslookup:
nslookup fileserver01
To query a set DNS server:
nslookup fileserver01 10.0.0.10
Several ipconfig commands are useful too:
ipconfig /allshows DNS servers, gateway, and adapter details.ipconfig /displaydnsshows cached DNS records.ipconfig /flushdnsclears the local DNS cache.ipconfig /registerdnsrefreshes DNS registration for the computer.
If a browser opens a site but an app fails by server name, the admin should test both the short name and the full domain name:
Resolve-DnsName fileserver01
Resolve-DnsName fileserver01.company.local
A simple triage flow
- Check the name: Run
Resolve-DnsNameornslookup. - Check the route: Run
ping, thentracertif needed. - Check the port: Run
Test-NetConnection server -Port 445. - Map the drive: Use
New-PSDriveornet use. - Clear bad cache: Run
ipconfig /flushdnsif DNS looks stale.
FAQ
Which is better, PowerShell or Command Prompt?
PowerShell is better for filtering, scripting, and detailed output. Command Prompt is better for quick checks and older scripts.
Why does a mapped drive work for one user but not another?
The users may have different permissions, cached credentials, or session types. Admin and standard user sessions can also see different mapped drives.
What port should be tested for Windows file shares?
Port 445 should be tested first. It is used by SMB, which handles most Windows file sharing.
Does flushing DNS fix every name problem?
No. It only clears the local cache. If the DNS server has the wrong record, the server-side record must be fixed.
What is the fastest first command for DNS trouble?
Resolve-DnsName servername in PowerShell or nslookup servername in Command Prompt gives a quick answer.
