We often need to map network drives. Especially if you are writing a package which installs something from a shared drive. It becomes important to map drives and give a drive letter for the same.
Net share is the command which can be used to accomplish the same. Below is the Powershell version of the same -
Adding a Network Drive
(New-Object -Com WScript.Network).MapNetworkDrive("x:" , "\\divine\d$")
That's it!
But this not the all about this. There might be further requirement to remove a network drive.
Listing the Network Drives
(New-Object -Com WScript.Network).EnumNetworkDrives()
Removing a Network Drive
(New-Object -Com WScript.Network).RemoveNetworkDrive("x:")
You can use EnumNetworkDrives() to find if particular share exists or not, then remove it. Anyways, there are several methods to do something, my job was just to give your tips not thesis.
Enjoy!!
Net share is the command which can be used to accomplish the same. Below is the Powershell version of the same -
Adding a Network Drive
(New-Object -Com WScript.Network).MapNetworkDrive("x:" , "\\divine\d$")
That's it!
But this not the all about this. There might be further requirement to remove a network drive.
Listing the Network Drives
(New-Object -Com WScript.Network).EnumNetworkDrives()
Removing a Network Drive
(New-Object -Com WScript.Network).RemoveNetworkDrive("x:")
You can use EnumNetworkDrives() to find if particular share exists or not, then remove it. Anyways, there are several methods to do something, my job was just to give your tips not thesis.
Enjoy!!