scenario: user loses permissions to their file share or user folder
goal: identify the user that has a matching username in AD but lost permissions to their folder
issues: I can find the users that have permissions to their folder and I can find other users. I am having issues when the user lost permissions to the folder and just focusing on that user and not the other ones like "administrators, users, " or common system accounts.
The scripting guy post helped me get further than my original code:
http://blogs.technet.com/b/heyscriptingguy/archive/2009/09/14/hey-scripting-guy-september-14-2009.aspx
I have numerous versions below and after a few hours am giving up for the night. Please help!
The section in bold is where I am struggling with logic to show me results of only users that have the same AD name as the folder name, but do not have permissions to that folder.
Import-Module ActiveDirectory cls $OutFile = "c:\scripted\share_folder_permission.csv" Del $OutFile $RootPath = "c:\users\" #get-user \\FILESHARE\users\$_.$UserName #$rootpath = "\\FILESHARE\users" #$username='DOMAIN\MYLOGIN205' $Folders = dir $RootPath | where {$_.psiscontainer -eq $true} foreach ($Folder in $Folders){ $username='DOMAIN\' + $Folder.Name $acl = Get-Acl -Path $Folder.Fullname #$acl.Access |ForEach-Object { $_.identityReference.value | Where-Object { $_ -eq $username }} #$acl.Access | ForEach-Object { $_.identityReference.value | Where-Object { $_ -eq $username } } { $acl.Access | ForEach-Object { $_.identityReference.value | Where-Object { $_ -ne $username } } { $adaccount = Get-QADUser $folder if ($adaccount.accountisenabled){ $outinfo = "user " + $username + " " + $folder.fullname + " does not have access" Add-Content -Value $OutInfo -Path $OutFile } }<#if ($_.identityReference.value -eq $username){ $outinfo = "user " + $username + " " + $folder.fullname + " has access" Add-Content -Value $OutInfo -Path $OutFile } #> #if ($_.access -ne $username){ #$outinfo = "user " + $username + " " + $folder.fullname + " does not have access" #Add-Content -Value $OutInfo -Path $OutFile #} #end foreach for acl loop } #end searching folder in folders #