Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Audit Fileshare from Hybrid Worker
Param(
[string]$ServerPath,
[string]$AuditShare,
[string]$OutputFolder
)
$ResultPath = "c:\sharepointfiles"
$Filename = $OutputFolder
$TargetShare = "$Serverpath\$AuditShare"
#About to Audit the Folder
write-output "$targetServer audit starting"
$Folders = dir $targetshare
ForEach ($Folder In $Folders){
$ACLs = Get-Acl $Folder.FullName | ForEach-Object { $_.Access }
}
#Output Results from above to (this folder is precreated for this example)
$ACLs >> "$ResultPath\$AuditShare-$Filename.txt"
#check members of the Global Group
$globalgroups = ($ACLs | where {$_.identityreference -like '*GG*'}).Identityreference.Value.Split("\")[1]
ForEach ($GlobalGroup in $GlobalGroups)
{
$groupmembers = (Get-ADGroupMember -identity $globalgroup).name
$groupmembers >> "$ResultPath\$AuditShare-$globalgroup.name-$Filename.txt"
}
Write-Host "Audit Completed. Results saved to $ResultPath"
write-host "sending all files to zip"
$FilesTocompress = Get-ChildItem C:\sharepointfiles\*$Filename*.*
Compress-Archive $FilesTocompress -DestinationPath "c:\sharepointfiles\$AuditShare-$Filename.zip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.