<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx</link><description>&amp;#160; Summary : Guest blogger Sean Kearney shows you how to use Windows PowerShell to create shared folders and set permissions on a Windows desktop. &amp;#160; Hey, Scripting Guy! How can I use Windows PowerShell to create shares? -- SK &amp;#160; Hello SK</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3576186</link><pubDate>Sun, 02 Jun 2013 19:10:30 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3576186</guid><dc:creator>Share Name NOT being created correctly in Server 2008R2</dc:creator><description>&lt;p&gt;Hi Ed - I am using the following script which does create the folder and share / security permissions but does NOT set the Share Name correctly. It is defaulting to FredFlintstone with no &amp;quot;$&amp;quot;. &lt;/p&gt;
&lt;p&gt;Shouldn&amp;#39;t the Share Name be able to be set the same as Win Server 2003?&lt;/p&gt;
&lt;p&gt;$NasPath = &amp;#39;Z:\EDrives\FredFlintstone&amp;#39;&lt;/p&gt;
&lt;p&gt;$Shares=[WMICLASS]&amp;#39;WIN32_Share&amp;#39;&lt;/p&gt;
&lt;p&gt;$ShareName=&amp;#39;FredFlintstone$&amp;#39;&lt;/p&gt;
&lt;p&gt;New-Item -type directory -Path $NasPath&lt;/p&gt;
&lt;p&gt;$Shares.Create($NasPath,$ShareName,0)&lt;/p&gt;
&lt;p&gt;$Acl = Get-Acl $NasPath&lt;/p&gt;
&lt;p&gt;$Ar = New-Object system.security.accesscontrol.filesystemaccessrule(&amp;#39;Fred Flintstone&amp;#39;,&amp;#39;FullControl&amp;#39;,&amp;#39;ContainerInherit, ObjectInherit&amp;#39;, &amp;#39;None&amp;#39;, &amp;#39;Allow&amp;#39;)&lt;/p&gt;
&lt;p&gt;$Acl.AddAccessRule($Ar)&lt;/p&gt;
&lt;p&gt;Set-Acl $NasPath $Acl&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3576186" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3570248</link><pubDate>Wed, 01 May 2013 20:03:06 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3570248</guid><dc:creator>Jason M. Johnston</dc:creator><description>&lt;p&gt;Ed are you saying that you can use Icacls to modify the permissions of the share as well as files?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3570248" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3556977</link><pubDate>Thu, 07 Mar 2013 00:55:28 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3556977</guid><dc:creator>Joejoeinc</dc:creator><description>&lt;p&gt; you are missing a closing bracket when you create your New-Share Function&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3556977" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3524935</link><pubDate>Tue, 09 Oct 2012 15:25:51 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3524935</guid><dc:creator>Knuckle-Dragger</dc:creator><description>&lt;p&gt;thanks&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3524935" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3517247</link><pubDate>Fri, 31 Aug 2012 02:29:42 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3517247</guid><dc:creator>iconoclasticcreations</dc:creator><description>&lt;p&gt;@LernerML&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t want certain directories shared, you could use this snippet:&lt;/p&gt;
&lt;p&gt;$badpaths = &amp;quot;C:\applications&amp;quot;,&amp;quot;C:\applications\someapp&amp;quot;,&amp;quot;C:\temp&amp;quot;,&amp;quot;C:\newshare&amp;quot;&lt;/p&gt;
&lt;p&gt;$servers = &amp;quot;Server1&amp;quot;,&amp;quot;Server2&amp;quot;,&amp;quot;Server3&amp;quot;&lt;/p&gt;
&lt;p&gt;foreach($server in $servers){&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;$found = Get-WMIObject Win32_share -ComputerName $server&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;foreach($share in $found){&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if($badpaths -contains $share.path){&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Share.Delete()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;You could also check for shared local printers with ($share.type -eq 1)&lt;/p&gt;
&lt;p&gt;It&amp;#39;d be really cool if you could see who created the share, and delete them based on creator, but I&amp;#39;m not that savvy. :(&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3517247" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3513252</link><pubDate>Wed, 08 Aug 2012 21:37:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3513252</guid><dc:creator>OldDog1</dc:creator><description>&lt;p&gt;Looks like the guys left out a couple of &amp;quot;)&amp;quot;&lt;/p&gt;
&lt;p&gt;Try this:&lt;/p&gt;
&lt;p&gt;Function NEW-SHARE ($Foldername, $Sharename) { &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# Test for existence of folder, if not there then create it &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF (!(TEST-PATH $Foldername)) { &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NEW-ITEM $Foldername -type Directory } &lt;/p&gt;
&lt;p&gt;# Create Share but check to make sure it isn’t already there &lt;/p&gt;
&lt;p&gt;# &lt;/p&gt;
&lt;p&gt;If (!(GET-WMIOBJECT Win32_Share -filter &amp;quot;name=$Sharename&amp;quot;)) { &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Shares=[WMICLASS]&amp;quot;WIN32_Share&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Shares.Create($Foldername,$Sharename,0) &lt;/p&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3513252" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3503583</link><pubDate>Wed, 13 Jun 2012 05:36:15 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3503583</guid><dc:creator>LearnerML</dc:creator><description>&lt;p&gt;I have a opposite scenario. Users in the network have shared the folders &amp;amp; I have to stop them. Any chance by which I can do it with single powershell script?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3503583" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3469791</link><pubDate>Thu, 08 Dec 2011 15:52:48 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3469791</guid><dc:creator>RPS</dc:creator><description>&lt;p&gt;How do you perform the following on a remote computer?: &lt;/p&gt;
&lt;p&gt;$Shares=[WMICLASS]&amp;quot;WIN32_Share&amp;quot;&lt;/p&gt;
&lt;p&gt;I can tell it is different than gwmi win32_share -cn [remote]&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3469791" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3467546</link><pubDate>Mon, 28 Nov 2011 11:35:51 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3467546</guid><dc:creator>Frank Peter Schultze</dc:creator><description>&lt;p&gt;The New-Share function will work if you add&lt;/p&gt;
&lt;p&gt;$Shares=[WMICLASS]&amp;quot;WIN32_Share&amp;quot;&lt;/p&gt;
&lt;p&gt;before the $Shares.Create line&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3467546" width="1" height="1"&gt;</description></item><item><title>re: How to Use PowerShell to Create Shared Folders in Windows 7</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx#3445593</link><pubDate>Sun, 07 Aug 2011 21:27:07 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3445593</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Panda you could use sendkeys from the wshshell object, or you could try to use WASP from CodePlex. &lt;/p&gt;
&lt;p&gt;@Davis check the Scripting Guys Script Repository ... I know we have some cluseter scripts else check MSDN &lt;/p&gt;
&lt;p&gt;@Joe of course I did :-) I like to Use Icacls to do permissions, but I have an article coming up in which I am using WMI methods.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445593" width="1" height="1"&gt;</description></item></channel></rss>