This is the batch commands I use to open a window with a mapped drive:
net use X: "\\SERVERNAME\FOLDER" /user:"USER" "PASSWORD"
START X:\
What is the PowerShell version of this?
Both of your commands work as-is in PowerShell:
net refers to the net.exe external program (a standard Windows utility), which PowerShell can equally call.
On Windows 8 / Windows Server 2012 or higher, you can use the New-SmbMapping cmdlet as an alternative to net use.
Note that while PowerShell cmdlets are generally more secure by not allowing passwords to be specified as plain text and requiring a credential object instead (see Get-Credential), this appears not to be the case with New-SmbMapping.
While start is an internal cmd.exe command, PowerShell has an alias named start for its own Start-Process cmdlet; if you pass a drive specification, the two commands work the same.
Invoke-Item cmdlet (Invoke-Item X:\),
$env:PATH search for executables is performed).X:, Invoke-Item opens File Explorer in whatever directory is current on that drive (by contrast, Start-Process and cmd.exe's start open the target drive's root directory).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With