Set-Location : Cannot find drive. A drive with the name 'P' does not exist.


hello all,

i have strange problem network drives mapping , using in powershell. if map network drive first time set-location , able browse thought drive. if dissconect drive , re-create drive again, not able set-location , browse drive anymore...

$pdrive = "\\sharename\projects$\p1757_xxx"
(new-object -com wscript.network).mapnetworkdrive("p:",$pdrive)
set-location p: working :-)
set-location c:
(new-object -com wscript.network).removenetworkdrive("p:")

$pdrive = "\\sharename\projects$\p1757_xxx"
(new-object -com wscript.network).mapnetworkdrive("p:",$pdrive)
set-location p: not working :-(

set-location : cannot find drive. drive name 'p' not exist.
at line:1 char:13
+ set-location <<<<  p:
    + categoryinfo          : objectnotfound: (p:string) [set-location], drivenotfoundexception
    + fullyqualifiederrorid : drivenotfound,microsoft.powershell.commands.setlocationcommand

share showing in psdrive , on net use, not able use thought powershell. same problem if map , remove networkdrive net use... in cmd network drive accessiable after recreation?????

try setting "updateprofile" true:

(new-object -com wscript.network).mapnetworkdrive("p:",$pdrive,"true")

http://msdn.microsoft.com/en-us/library/8kst88h6(v=vs.85).aspx

karl


blog: http://unlockpowershell.wordpress.com
book: windows powershell 2.0 bible
e-mail: -join ("6b61726c6d69747363686b65406d742e6e6574"-split"(?<=\g.{2})",19|%{[char][int]"0x$_"})


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com