great script, can this be manipulated to export folder permissions on a directory level but only expand on users and not groups in AD?
I need a script which will only give who has what permission on a folder i.e. S:\DEPT\FOLDER1 ... FOLDER2...FOLDER3. I need the permissions each person has on each folder.
these are the scripts I have, I need them to merge together, if you could help me I would be very grateful.
This expands all groups like your script.bolded text
Import-Module ActiveDirectory
$Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select name -expandproperty name)
$Table = @()
$Record = [ordered]@{
"Group Name" = ""
"Name" = ""
"Username" = ""
}
Foreach ($Group in $Groups)
{
$Arrayofmembers = Get-ADGroupMember -identity $Group | select name,samaccountname
foreach ($Member in $Arrayofmembers)
{
$Record."Group Name" = $Group
$Record."Name" = $Member.name
$Record."UserName" = $Member.samaccountname
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord
}
}
$Table | export-csv "C:\temp\SecurityGroups.csv" -NoTypeInformation
bolded text AND this show folder level permissions but not excluding groups, which is what I need. no groups only users
$exclude = @(
'CREATOR OWNER'
'NT AUTHORITY\SYSTEM'
'BUILTIN\Administrators'
'HTBPLC\Domain Admins'
)
$RootPath = "S:\Groups\DEPARTMENTS"
$folders = [array](Get-Item -Path $RootPath)
$folders += Get-ChildItem -Path $RootPath -Recurse -Directory
$acls = foreach ($Folder in $Folders){
get-acl $Folder.fullname |
Select-Object -ExpandProperty Access |
Where-Object {
-not $.IsInherited -and
$exclude -notcontains $.IdentityReference
} |
Select-Object -Property *,@{
'Name' = 'Folder'
'Expression' = {
$Folder.FullName
}}
}
$acls | Export-Csv -NoTypeInformation -Path C:\NTFS\DEPARTMENTS1.csv