/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" Some Powershell News "," PowerShell Import and Export a DirectoryTree and S... "," PowerShell How Can I Query a Text File and Retriev... "," PowerShell Import Shares and Security info From CS... "," An other PowerShell Blog is born "," Windows PowerShell: TFM "," PowerShell Export Shares and Security info to CSV "," powershell (Monad) Home on computerperformance.co.... "," PowerShell in Action "," PowerShell out-PropertyGrid (MSH view-Object) "," ")

Thursday, May 11, 2006

 


PowerShell make a drive of an UNC path



I see a lot of post lately about using wscript.Network to make a networkmapping,
like this :

$net = $(New-Object -Com WScript.Network)
$net.MapNetworkDrive("u:", "\\computer\share")

e.g. here :

Can you map a drive with PowerShell?

and here.

http://www.computerperformance.co.uk/ezine/ezine110.htm

but there is a more native way to do this on PowerShell,

*edit* but as Jacques (links to French blog janel) pointed out to me in the comments, this is only valid for the PowerShell so you can not use it to map a drive and use it from the CMD prompt or the GUI (what is a big difference ) but if you use it in the powershell it has a lot of power as naming the drive with more letters, a path, or mapping to a registrykey.

New-PSDrive HKCR Registry -root
HKEY_CLASSES_ROOT

or a registry path e.g. the PowerShell configuration

New-PSDrive PsConfig Registry -root
HKLM:\software\Microsoft\powershell\1\ShellIds

and ofcourse as mentioned an UNC path :

just type new-PsDrive and you can make an PowerShell drive of a Networkshare :

MowPS>new-psdrive

cmdlet new-psdrive at command pipeline position 1
Supply values for the following parameters:

Name: u
PSProvider: filesystem
Root: \\Computer\share

Name Provider Root
---- -------- ----
u FileSystem \\Computer\share

gr /\/\o\/\/
Tags :


Comments:
Anonymous Jacques
The limitation with new-psdrive in this context is that the mapped drive will only be accessible from within the PowerShell runspace that created it, whereas the MapNetworkDrive method will expose the mapped drive to the whole system.
 
Blogger /\/\o\/\/
Good Point,
I missed that difference.

Thanks for the Comment

Greetings /\/\o\/\/
 
Post a Comment

Links to this post:

Create a Link



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?