Browse to Remote Passworded Shares

Have you ever tried to use PowerShell to browse to a remote hard drive by typing 'cd \\server\c$'? Well, unless a lot of things are in line, that just wont work so easily. I found a simple way to 'open the session' with the remote computer, allowing you to set-location right over to the drive. All you have to do is set your credentials in the .ps1 file, then run it with a server specified.

Unlock-Server IISServ
Unlocks IISServ and browses to C$ (by default settings)

Here's the difference:

PS C:\PowerShell> cd \\iisserv\c$
Set-Location : Cannot find path '\\iisserv\c$' because it does not exist.
At line:1 char:3
+ cd <<<< \\iisserv\c$
PS C:\PowerShell> .\Unlock-Server.ps1 iisserv
The command completed successfully.

PS Microsoft.PowerShell.Core\FileSystem::\\iisserv\c$>

Here's the simple file:

#unlock server and start share session

$user = "YourAdminUserHere"
$password = "YourPasswordHere"
$drive = "c$"

net use \\$args /user:$user $password
set-location \\$args\$drive

If you just want the script to 'unlock' the server and prepare it for any location you want to specify, remove the line that browses to the location ( set-location \\$args\$drive ).

I hope someone else finds this as useful as I have for running commands on remote hard drives from your PowerShell session.