{"id":52463,"date":"2009-09-15T03:01:00","date_gmt":"2009-09-15T03:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2009\/09\/15\/hey-scripting-guy-how-can-i-tell-to-which-folders-a-user-has-been-granted-or-denied-access\/"},"modified":"2009-09-15T03:01:00","modified_gmt":"2009-09-15T03:01:00","slug":"hey-scripting-guy-how-can-i-tell-to-which-folders-a-user-has-been-granted-or-denied-access","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-tell-to-which-folders-a-user-has-been-granted-or-denied-access\/","title":{"rendered":"Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?"},"content":{"rendered":"<p><span class=\"sbmLink\">   <\/p>\n<table cellspacing=\"1\" cellpadding=\"1\">\n<tbody>\n<tr>\n<td class=\"sbmText\">Share this post: <\/td>\n<td><a title=\"Post it to Backflip!\" href=\"http:\/\/www.backflip.com\/add_page_pop.ihtml?url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/backflip4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Buddymark!\" href=\"http:\/\/buddymarks.com\/s_add_bookmark.php?bookmark_url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;bookmark_title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/buddymar4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Del.icio.us!\" href=\"http:\/\/del.icio.us\/post?url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/deliciou4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Digg!\" href=\"http:\/\/digg.com\/submit?phase=2&amp;url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/digg14.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Facebook!\" href=\"http:\/\/www.facebook.com\/sharer.php?u=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;t=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/telligent.evolution.components.attachments\/13\/4982\/00\/00\/01\/76\/53\/19\/facebook.JPG\" \/><\/a><\/td>\n<td><a title=\"Post it to Furl!\" href=\"http:\/\/www.furl.net\/store?s=f&amp;to=0&amp;u=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;ti=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/furl4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Netvouz!\" href=\"http:\/\/netvouz.com\/action\/submitBookmark?url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/netvouz4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Reddit!\" href=\"http:\/\/reddit.com\/submit?url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/reddit4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Spurl!\" href=\"http:\/\/www.spurl.net\/spurl.php?v=3&amp;url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/spurl8.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Technorati!\" href=\"http:\/\/technorati.com\/faves\/?add=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/technora4.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Wists!\" href=\"http:\/\/www.wists.com\/?action=add&amp;url=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;title=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wists9.png\" \/><\/a><\/td>\n<td><a title=\"Post it to Yahoo!\" href=\"http:\/\/myweb.yahoo.com\/myresults\/bookmarklet?u=http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/09\/15\/hey-scripting-guy-september-15-2009.aspx&amp;t=Hey, Scripting Guy! How Can I Tell to Which Folders a User Has Been Granted or Denied Access?\" target=\"_blank\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/yahoo9.png\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> <\/span>  <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\" \/>Hey, Scripting Guy! I need to find out what folders a user has specifically been granted or denied access to. I do not need the specific rights that were granted. I only need to find out where the user was specifically granted or denied access. The reason for this is I am trying to clean up permissions on some of our shared directories, and I am having a hard time finding explicit permissions. As you know, when a user has been explicitly denied, it overrides other permissions. Also when a user has been granted specific permissions, they add to rights gained via groups. All of this is quite confusing. Needless to say, these permissions were granted by some clown who did not know what he was doing, and of course the clown has now been promoted to another department and is too good to answer questions from a storage administrator. Can you whip up a custom script for me?    <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">&#8212; JS   <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\" \/>Hello JS, <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">Microsoft Scripting Guy Ed Wilson here. I recently had a scoping call with a large customer about providing some Windows PowerShell 2.0 training for them. During the phone call, I mentioned that reporting on certain configuration settings is best carried out by using tools such as <a href=\"http:\/\/www.microsoft.com\/systemcenter\/en\/us\/default.aspx\"><font face=\"Segoe\">System Center<\/font><\/a> and that I did not think in the large enterprise writing scripts to detect the installation status of a particular hotfix was something that would be needed. They promptly informed me that, while it might be possible to obtain such a report, it might very well take more than a week to have it produced because the System Center team is responsible for managing System Center and not for producing ad hoc reports for the server administration team. <span>&#160;<\/span>It is a shame, but it seems that most IT departments these days run extremely lean, and to accomplish their core mission, they must carefully guard against being randomized in too many different directions. Of course, this is not necessarily your problem; however, it might explain why your colleague seems to be a bit preoccupied with his new job. Another explanation might be that your co-worker does not remember what was done or why. If the documentation for such changes was not made, it might be that any forthcoming assistance would be useless drivel.     <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">A good script is better than a clueless co-worker any day. The Get-SecurityOfFolders.ps1 script will search through an array of folders that you specify, and find which folders a specific user has been granted explicit security permissions to. The complete Get-SecurityOfFolders.ps1 script is seen here.    <\/p>\n<p style=\"margin: 15pt 12pt 0pt 0in\" class=\"CodeBlockScreenedHead\"><strong>Get-SecurityOfFolders.ps1     <\/p>\n<p>   <\/strong><\/p>\n<p style=\"margin: 15pt 17.3pt 0.25in 0in\" class=\"CodeBlockScreened\"><span style=\"font-size: 9.5pt\"><font style=\"background-color: #f2f2f2\"><font face=\"Lucida Sans Typewriter\">$user = &#8216;nwtraders\\bob&#8217;          <br \/>$folders = &quot;c:\\fso&quot;,&quot;C:\\fso1&quot;,&quot;c:\\fso2&quot;           <br \/>$acls = Get-Acl -path $folders          <br \/>$outputObject = @()          <\/p>\n<p>Foreach($acl in $acls)          <br \/>{           <br \/><span>&#160;<\/span>$folder = (convert-path $acl.pspath)          <br \/><span>&#160;<\/span>Write-Progress -act &quot;Getting Security&quot; -status &quot;checking $folder&quot; -percent ($i\/ $folders.count*100)          <br \/><span>&#160;<\/span>$object = New-Object -TypeName PSObject          <br \/><span>&#160; <\/span>Foreach($access in $acl.access)          <br \/><span>&#160; <\/span>{           <br \/><span>&#160;&#160;&#160; <\/span>Foreach($value in $access.identityReference.Value)          <br \/><span>&#160;&#160;&#160;&#160; <\/span>{           <br \/><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span>if ($value -eq $user)           <br \/><span>&#160; <\/span><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>{           <br \/><span>&#160;&#160;&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name Folder -Value $folder          <br \/><span>&#160;&#160;&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name user -Value $user          <br \/><span>&#160;&#160;&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name mode -Value $access.AccessControlType          <br \/><span>&#160;&#160;&#160;&#160; <\/span>$outputObject += $object          <br \/><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>}           <br \/><span>&#160;&#160;&#160;&#160; <\/span>} #end foreach value          <br \/><span>&#160; <\/span>} # end foreach access          <br \/>$i++          <br \/>} #end Foreach acl          <br \/>$outputObject | Format-Table -property * -autosize          <\/p>\n<p>       <\/font><\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The first thing that is done in the Get-SecurityOfFolders.ps1 script is to specify a user name. The user is the one whose security rights to folders will be determined. The folders are an array of folder paths. You could also use the <b>Get-ChildItem<\/b> cmdlet to obtain a collection of folders, but that would entail a bit more work. You might also wish to modify these two value assignments and turn them into command-line parameters. You will need to modify these two values before running the script, unless you actually have a user named <b>nwtraders\\bob<\/b> and you have folders <b>c:\\fso \u2013 c:\\fso2<\/b>. The two lines are shown here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">$user = &#8216;nwtraders\\bob&#8217;        <br \/>$folders = &quot;c:\\fso&quot;,&quot;C:\\fso1&quot;,&quot;c:\\fso2&quot;         <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">Now we use a shortcut to grab the security objects from the folders. Because the <b>Get-Acl<\/b> cmdlet will accept an array of strings for the folder paths, the array of strings stored in the <b>$folders<\/b> variable is passed to the path argument of the <b>Get-Acl<\/b> cmdlet. The resulting collection of <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.security.accesscontrol.directorysecurity.aspx\">System.Security.AccessControl.DirectorySecurity<\/a> .NET Framework classes are stored in the <b>$acls<\/b> variable. This is seen here:    <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">$acls = Get-Acl -path $folders       <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">After you have collected the access control lists and stored them in the variable <b>$acls<\/b>, it is time to create an empty array. The <b>$outputObject<\/b> variable will be used to store the custom access object that will be created later on in the script. It is created here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">$outputObject = @()       <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">You can walk through the collection of access control lists by using the <b>Foreach<\/b> statement. This is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">Foreach($acl in $acls)       <br \/>{         <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The path to the folder the specific user has been granted rights to is obtained from the <b>pspath<\/b> property of the System.Security.AccessControl.DirectorySecurity .NET Framework class. The <b>pspath<\/b> property is added by Windows PowerShell. When you look at the <b>pspath<\/b> property value, it contains the path to the folder, but not in a very usable fashion. This is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">PS C:\\&gt; (Get-Acl c:\\fso).pspath       <br \/>Microsoft.PowerShell.Core\\FileSystem::C:\\fso        <br \/>PS C:\\&gt;        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">To translate the <b>pspath<\/b> property value into a path that is more useful for the script, you can use the <b>Convert-Path<\/b> cmdlet. The <b>Convert-Path<\/b> cmdlet will translate a Windows PowerShell path into a path that can be used by a Windows PowerShell provider. This is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">PS C:\\&gt; Convert-Path -path (Get-Acl c:\\fso).pspath       <br \/>C:\\fso        <br \/>PS C:\\&gt;        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">In the Get-SecurityOfFolders.ps1 script, the converted path is stored in the <b>$folder<\/b> variable, which is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160;<\/span>$folder = (convert-path \u2013path $acl.pspath)        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The <b>Write-Progress<\/b> cmdlet is used to provide a visual indicator of the progress in obtaining the ACLs from each folder. The activity is the gathering of security information. The status is the current folder that is being scanned. The percent complete is calculated by using the number of folders in the <b>$folders<\/b> array. When the Get-SecurityOfFolders.ps1 script is run, this progress bar is displayed:     <\/p>\n<p style=\"margin: 9pt 0in 4pt\" class=\"Fig-Graphic\"><img decoding=\"async\" style=\"width: 600px;height: 297px\" title=\"Image of progress bar displayed when script is run\" alt=\"Image of progress bar displayed when script is run\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/september\/hey0915\/hsg-09-15-09-01.jpg\" width=\"600\" height=\"297\" \/>    <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The <b>Write-Progress<\/b> command is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160;<\/span>Write-Progress -activity &quot;Getting Security&quot; -status &quot;checking $folder&quot; -percent ($i\/ $folders.count*100)        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">It is now time to create the custom Windows PowerShell object that will hold the security information for the specific user on each of the folders. To do this, use the <b>New-Object<\/b> cmdlet and specify the <b>TypeName<\/b> of PSObject. The resulting custom object is stored in the <b>$object<\/b> variable as seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160;<\/span>$object = New-Object -TypeName PSObject        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">Because the user name that has been granted rights to a folder is stored in the value of the <b>identityReference<\/b> property of the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.security.principal.ntaccount.aspx\">System.Security.Principal.NTAccount<\/a> .NET Framework class, it is necessary to somehow gain access to the <b>NTAccount<\/b> class.<span>&#160; <\/span>To do this, each of the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.security.accesscontrol.filesystemaccessrule.aspx\">System.Security.AccessControl.FileSystemAccessRule<\/a> .NET Framework classes that are returned by querying the <b>access<\/b> property of the <b>DirectorySecurity<\/b> object are queried. The <b>Foreach<\/b> statement is used to walk through the collection of <b>FileSystemAccessRules<\/b>, as seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160; <\/span>Foreach($access in $acl.access)        <br \/><span>&#160; <\/span>{         <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">After a <b>FileSystemAccessRule<\/b> has been obtained and stored in the <b>$access<\/b> variable, the <b>NTAccount<\/b> class is obtained by referencing the <b>identityReference<\/b> property.<span>&#160; <\/span>The value contained in the <b>value<\/b> property is stored in the <b>$value<\/b> variable as seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160;&#160;&#160; <\/span>Foreach($value in $access.identityReference.Value)        <br \/><span>&#160;&#160;&#160;&#160; <\/span>{         <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">If the value stored in the <b>$value<\/b> variable is equal to the string that is stored in the <b>$user<\/b> variable, the <b>Add-Member<\/b> cmdlet is used to add three different note properties to the custom PSObject that is stored in the <b>$object<\/b> variable.     <\/p>\n<p style=\"margin: 15pt 12pt 0.25in 0in\" class=\"Readeraidonly\">The use of the custom PSObject was a significant feature in the solutions submitted by our expert commentators during the <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/tags\/2009+Summer+Scripting+Games\/default.aspx\"><font face=\"Segoe\">2009 Summer Scripting Games<\/font><\/a>. Those guest commentaries, as well as my review of some of the solutions proposed by Games participants, can be seen in the <font face=\"Segoe\">Hey, Scripting Guy! archives<\/font>.    <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The first <b>NoteProperty<\/b> is the folder name stored in the <b>$folder<\/b> variable; the second is the user name stored in the <b>$user<\/b> variable; and the last <b><span>&#160;<\/span>NoteProperty<\/b> is the access mode (either denied or granted). This last value is received from the <b>AccessControlType<\/b> property from the <b>FileSystemAccessRule<\/b> .NET Framework class stored in the <b>$access<\/b> variable. This is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\"><span>&#160;&#160;&#160;&#160;&#160;&#160; <\/span>if ($value -eq $user)         <br \/><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>{         <br \/><span>&#160;&#160;&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name Folder -Value $folder        <br \/><span>&#160; <\/span><span>&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name user -Value $user        <br \/><span>&#160;&#160;&#160;&#160; <\/span>$object | Add-Member -MemberType NoteProperty -Name mode -Value $access.AccessControlType        <br \/><span>&#160;&#160;&#160;&#160; <\/span>$outputObject += $object        <br \/><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/span>}         <br \/><span>&#160;&#160;&#160;&#160; <\/span>} #end foreach value        <br \/><span>&#160; <\/span>} # end foreach access        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The value of the <b>$i <\/b>variable is incremented by one because it is used to track the progress through the folders for the <b>Write-Progress<\/b> command. This is done just before closing the curly brackets for the <b>Foreach<\/b> statement that is used to walk through the access control lists:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">$i++       <br \/>} #end Foreach acl        <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">It is time to display the results that are stored in the <b>$outputObject<\/b> variable. Because the <b>$outputObject<\/b> contains an array of custom Windows PowerShell objects, the output can be manipulated by using standard Windows PowerShell cmdlets. To display a table, pipe the <b>$outputObject<\/b> variable to the <b>Format-Table<\/b> cmdlet, select the properties you are interested in seeing and then autosize it to maximize screen real estate. The command to produce the output is seen here:     <\/p>\n<p style=\"margin: 4pt 0in 7pt;background: #f2f2f2\" class=\"CodeBlock\"><span style=\"font-size: 9.5pt\"><font face=\"Lucida Sans Typewriter\">$outputObject | Format-Table -property * -autosize       <\/p>\n<p>     <\/font><\/span><\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">The output produced by the script is seen here:   <\/p>\n<p style=\"margin: 9pt 0in 4pt\" class=\"Fig-Graphic\"><img decoding=\"async\" style=\"width: 600px;height: 297px\" title=\"Image of output produced when script is run\" alt=\"Image of output produced when script is run\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2009\/september\/hey0915\/hsg-09-15-09-02.jpg\" width=\"600\" height=\"297\" \/>    <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">JS, this concludes our discussion of identifying folders to which a specific user has rights.     <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">If you want to know exactly what we will be discussing tomorrow, follow us on <a href=\"http:\/\/www.twitter.com\/scriptingguys\/\" target=\"_blank\">Twitter<\/a> or <a href=\"http:\/\/www.new.facebook.com\/group.php?gid=5901799452\" target=\"_blank\"><font face=\"Segoe\">Facebook<\/font><\/a>. If you have any questions, send e-mail to us at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a> or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.     <\/p>\n<p style=\"margin: 0in 0in 8pt\" class=\"MsoNormal\">\n<p>&#160;<\/p>\n<\/p>\n<p style=\"margin-left: 0in\"><b><span>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/span><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Share this post: Hey, Scripting Guy! I need to find out what folders a user has specifically been granted or denied access to. I do not need the specific rights that were granted. I only need to find out where the user was specifically granted or denied access. The reason for this is I am [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[62,3,63,45],"class_list":["post-52463","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-dacls-and-sacls","tag-scripting-guy","tag-security","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Share this post: Hey, Scripting Guy! I need to find out what folders a user has specifically been granted or denied access to. I do not need the specific rights that were granted. I only need to find out where the user was specifically granted or denied access. The reason for this is I am [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=52463"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52463\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=52463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=52463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=52463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}