How do I create a new shared drive with the provided credentials on the computer that is running the script?

Is there a PowerShell cmdlet that does that?

link|improve this question
1  
I don't understand what you mean by shared driver. Do you mean shared drive? – Ben Pilbrow Aug 28 '11 at 11:52
@Ben: Yes, shared drive. Sorry it's a typo... – the_drow Aug 28 '11 at 14:09
And now: Do you mean to create a public share or how to map a public share to a drive letter? – mailq Aug 28 '11 at 15:21
Sorry :/ I am asking how to map a public share to a drive letter. – the_drow Aug 29 '11 at 7:00
@mailq Why isn't this a real question? – the_drow Aug 30 '11 at 7:47
show 2 more comments
feedback

closed as not a real question by user48838, mailq, MDMarra, Ben Pilbrow, Shane Madden Aug 29 '11 at 4:24

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. See the FAQ for guidance on how to improve it.

2 Answers

This powershell function should work:

Function NEW-SHARE ($Foldername, $Sharename) { 
   # Test for existence of folder, if not there then create it 
   # 
   IF (!(TEST-PATH $Foldername)) { 
       NEW-ITEM $Foldername -type Directory } 
   # Create Share but check to make sure it isn’t already there 
   # 
   If (!(GET-WMIOBJECT Win32_Share -filter “name=$Sharename”) { 
       $Shares.Create($Foldername,$Sharename,0)} 
}

The following article on technet provides more information:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx

link|improve this answer
feedback

Just use "net use" inside your powershell scripts:

new use z: \\server\share /user:domain\username password

link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.