header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Get Folder Listing and ACL
Last Post 23 Dec 2008 10:35 AM by get-james. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
OolongUser is Offline
New Member
New Member
Posts:1
Avatar

--
22 Sep 2008 07:55 PM  

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....

ElanUser is Offline
New Member
New Member
Posts:28
Avatar

--
22 Sep 2008 11:39 PM  
Try:
$myobj = "" | Select-Object Folder,SizeMB,ACL | Format-Table -wrap
Elan Shudnow
http://www.shudnow.net
get-jamesUser is Offline
New Member
New Member
Posts:21
Avatar

--
23 Dec 2008 10:35 AM  

You can also format the results like this:

$a = Get-ChildItem -path $SYSPath -Filter *. -Recurse -force -Verbose
@(foreach($c in $a)
{
$fsz = ((Get-ChildItem $c.FullName -Recurse | Measure-Object length -sum).sum) / 1mb
$obj = "" | select Folder,"SizeMB"
$obj.Folder = $c
$obj.SizeMB = "{0:N2}" -f $fsz
$obj
}) | format-table -auto

Folder             SizeMB
------                ------
AdminScripts    0.13
iissamples          0.49
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer