In a windows batch file:
REM Batch File to map network drive NET USE H: \\server\share REM Disconnect a mapped network drive NET USE H: /d
In powershell 3.0 or above:
#this temporarily maps PSDrive to \\Server01\Public New-PSDrive -Name PSDrive -PSProvider FileSystem -Root \\Server01\Public #to make the drive available for other windows services, use the Persist keyword as follows: New-PSDrive -Name PSDrive -PSProvider FileSystem -Root \\Server01\Public -Persist #Use Get-PSDrive to get a list of mounted drives #Example of accessing the drive cd PSDrive: type PSDrive:\something.txt #To remove the drive Remove-PSDrive -Name PSDrive