<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx</link><description>I got the following question from a reader the other day: I've been trying to figure out how to change permissions on a folder in PowerShell. I've looked at the Get-Acl and Set-Acl, but I can only use them to copy the settings from a pre-existing object.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>infoblog &amp;raquo; PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#8971530</link><pubDate>Wed, 01 Oct 2008 15:59:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8971530</guid><dc:creator>infoblog &amp;raquo; PowerShell - Editing permissions on a file or folder</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog.a-foton.ru/index.php/2008/10/01/powershell-editing-permissions-on-a-file-or-folder/"&gt;http://blog.a-foton.ru/index.php/2008/10/01/powershell-editing-permissions-on-a-file-or-folder/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#8974206</link><pubDate>Thu, 02 Oct 2008 22:14:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974206</guid><dc:creator>Ronto</dc:creator><description>&lt;p&gt;Say... I get the following error when I try your first example to copy folder permissions:&lt;/p&gt;
&lt;p&gt;Set-Acl : The security identifier is not allowed to be the owner of this object&lt;/p&gt;
&lt;p&gt;Any ideas why?&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#8975289</link><pubDate>Fri, 03 Oct 2008 12:12:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8975289</guid><dc:creator>JohanS</dc:creator><description>&lt;p&gt;Good question.&lt;/p&gt;
&lt;p&gt;You're obviously getting this error because you're trying to change the owner of the object. By default NTFS will only allow you to set the owner of an object to:&lt;/p&gt;
&lt;p&gt;A: Yourself &lt;/p&gt;
&lt;p&gt;B: Administrators-group&lt;/p&gt;
&lt;p&gt;That's it.&lt;/p&gt;
&lt;p&gt;However, if you're an administrator or backup operator you can set it to any user, BUT this privilige is disabled by default and must be enabled before you can do so. In case you're wondering - this is a concious security restriction.&lt;/p&gt;
&lt;p&gt;There are no .NET or PowerShell specific ways of enabling this, but if we leave Microsoft-territory and visit the PowerShell Community Extensions project we find a way...&lt;/p&gt;
&lt;p&gt;I havent used PSCX that much and it's not a Microsoft product so any questions on them should be directed to www.codeplex.com/PowerShellCX rather than here, but here goes:&lt;/p&gt;
&lt;p&gt;Download and install PSCX from www.codeplex.com/PowerShellCX&lt;/p&gt;
&lt;p&gt;Set up a wrapper class for TokenPriviliege using the following syntax:&lt;/p&gt;
&lt;p&gt;$oTP = New-Object PSCX.Interop.TokenPriviliege&lt;/p&gt;
&lt;p&gt;Now, grant it to the current process:&lt;/p&gt;
&lt;p&gt;Set-Privilege $oTP&lt;/p&gt;
&lt;p&gt;You should now be able to change the owner of the folder to any user you wish.&lt;/p&gt;
&lt;p&gt;Have fun! / Johan&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#9044854</link><pubDate>Wed, 05 Nov 2008 21:06:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9044854</guid><dc:creator>Tony</dc:creator><description>&lt;p&gt;I would like to create a powershell script that would scour an OU for any users that are missing a home folder, create the folder on a NAS, apply the appropriate permissions and then set their AD profile to use this new location. Here is what i have so far, any assistance would be very helpfull:&lt;/p&gt;
&lt;p&gt;Get-QADUser -SizeLimit 0 -searchroot 'ou=***,ou=***,dc=***,dc=***,dc=***' | `&lt;/p&gt;
&lt;p&gt;where{$_.homedirectory -eq $null} | `&lt;/p&gt;
&lt;p&gt;foreach {&lt;/p&gt;
&lt;p&gt;	$NasPath = '\\NAS\'+$_.LogonName&lt;/p&gt;
&lt;p&gt;	New-Item -type directory -Path $NasPath&lt;/p&gt;
&lt;p&gt;	$Acl = Get-Acl $NasPath&lt;/p&gt;
&lt;p&gt;	$Ar = New-Object system.security.accesscontrol.filesystemaccessrule($_.LogonName,&amp;quot;FullControl&amp;quot;,&amp;quot;Allow&amp;quot;)&lt;/p&gt;
&lt;p&gt;	$Acl.RemoveAccessRule($Ar)&lt;/p&gt;
&lt;p&gt;	Set-Acl $NasPath $Acl&lt;/p&gt;
&lt;p&gt;	Set-QADUser $_ -ObjectAttributes @{'HomeDirectory'= $NasPath; 'HomeDrive'='Y'}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Tony&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#9860349</link><pubDate>Fri, 07 Aug 2009 19:18:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9860349</guid><dc:creator>ewookie</dc:creator><description>&lt;p&gt;When trying the sample code, I get the following error message after the last line:&lt;/p&gt;
&lt;p&gt;Set-Acl : The process does not possess the 'SeSecurityPrivilege' privilege whic&lt;/p&gt;
&lt;p&gt;h is required for this operation.&lt;/p&gt;
&lt;p&gt;I'm running the script under an account that has full control over the directory where I'm trying to create the new directory...&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#9863966</link><pubDate>Tue, 11 Aug 2009 10:45:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9863966</guid><dc:creator>JohanS</dc:creator><description>&lt;p&gt;Are you running the script in Vista with UAC turned on?&lt;/p&gt;
&lt;p&gt;Try running PowerShell with elevated privileges. (Run as administrator)&lt;/p&gt;
&lt;p&gt;/ Johan&lt;/p&gt;
</description></item><item><title>re: PowerShell - Editing permissions on a file or folder</title><link>http://blogs.msdn.com/johan/archive/2008/10/01/powershell-editing-permissions-on-a-file-or-folder.aspx#9935618</link><pubDate>Fri, 11 Dec 2009 11:04:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9935618</guid><dc:creator>Nisha</dc:creator><description>&lt;p&gt;Hi Johan,&lt;/p&gt;
&lt;p&gt;I too got the same error of &lt;/p&gt;
&lt;p&gt;Set-Acl : The security identifier is not allowed to be the owner of this object&lt;/p&gt;
&lt;p&gt;As per your comment above, I tried installing the PSCX from codeplex. I also installed it as a PS Plug-in. When I try, &lt;/p&gt;
&lt;p&gt;$oTP = New-Object PSCX.Interop.TokenPriviliege&lt;/p&gt;
&lt;p&gt;I get the following error:&lt;/p&gt;
&lt;p&gt;New-Object : Cannot find type [PSCX.Interop.TokenPriviliege]: make sure the assembly containing this type is loaded.&lt;/p&gt;
&lt;p&gt;I am running Powershell v 1.0&lt;/p&gt;
&lt;p&gt;Am I missing anything here?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Nisha&lt;/p&gt;
</description></item></channel></rss>