Reputation: 65496
then I run cmd /c net use h: /d
from the powershell command line it all succeeds
but when I run the same command in the powershell $profile script it asks for a manual confirmation.
Anyone know how to prevent the confirmation please?
Upvotes: 1
Views: 4314
Reputation: 31
(New-Object -ComObject WScript.Network).RemoveNetworkDrive("H:", 1, 1)
The second 1 at the end I believe is for bUpdateProfile. The drive would not disappear from the Explorer window unless that value was there.
Upvotes: 0
Reputation: 65496
I cannot find a way to force the net program to force the drive deletion, however I can use the following powershell script to control the Windows Script Host to
(New-Object -ComObject WScript.Network).MapNetworkDrive("H:", '\\SVNAS301\blah')
remove a mapping
(New-Object -ComObject WScript.Network).RemoveNetworkDrive("H:")
Or remove a mapping with force
(New-Object -ComObject WScript.Network).RemoveNetworkDrive("H:", 1)
Upvotes: 3