I'm trying to write a PS script that will help with Permission documentation. WebAdmin use our systems to implement various web apps but forget that we need the permissions documented in order to do disaster recovery.
Here is my script ... but my output keeps getting truncated ... (and I'm still not sure I'm getting the results I need).
The Script is supposed to find a remote directory, recurse the sub-directories, report the file size and the ACL on each.
Any suggestions would be great.
p.s. Thanks to "get-james" for a good part of this code.
$Stamp = get-date -uformat "%Y%m%d"
$UNCSys = "MAT-abc-xx123456"
$SYSPath = "C$\InetPub"
$UNCPath = "\\" +$UNCSys+ "\" +$SYSPath+ "\"
$SYSLabel = $UNCSys + "_" + $Stamp
$Newfile = "C:\Admin\FolderACL\logs\FolderList-"+$SYSLabel+".txt"
if (Test-Path $Newfile)
{
Remove-item $Newfile
}
$a = Get-ChildItem -path $UNCPath -Filter *. -Recurse -force -Verbose
$b = @{Expression = {$_.Folder};Label = "Folder";width = 20},
@{Expression = {$_.SizeMB};Label = "Size MB";width = 15},
@{Expression = {$_.ACL};Label = "ACL";width = 200}
@(foreach($c in $a)
{
$myobj = "" | Select-Object Folder,SizeMB,ACL
$fsz = ((Get-ChildItem $c.FullName -Recurse | Measure-Object length -sum).sum) / 1mb
$myobj.Folder = $c
$myobj.SizeMB = "{0:N2}" -f $fsz
$myobj.ACL = Get-Acl $c.FullName
out-file -filepath $Newfile -append -inputObject $myobj
})
My output looks like this:
Folder SizeMB ACL
------ ------ ---
AdminScripts 0.09 System.Security....
Folder SizeMB ACL
------ ------ ---
ftproot 0.00 System.Security....
Folder SizeMB ACL
------ ------ ---
wwwroot 3.62 System.Security....
Folder SizeMB ACL
------ ------ ---
aspnet_client 3.61 System.Security....