我正在尝试获取我们服务器上所有文件夹的文件夹信息和安全信息。但是我在这里对Powershell并不熟悉。介意帮助新手吗?
如何将安全 acl 通过管道传输到文本文件中?除了文件夹名称、大小、子文件夹计数的成员对象吗?
# Step 1 Get Folder Path
function Select-Folder($message='Select a folder', $path = 0) {
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, $message, 0, $path)
if ($folder -ne $null) {
$folder.self.Path
}
}
#Step 2:Search For Directories
$dirToAudit = Get-ChildItem -Path (Select-Folder 'Select some folder!') -recurse | Where {$_.psIsContainer -eq $true}
foreach ($dir in $dirToAudit)
{
#Step 3: Output: [Folder Path, Name, Security Owner, Size, Folder Count]
#Pipe To CSV Text File
Get-Acl -Path $dir.FullName | Select-Object PSPath, Path,Owner | export-csv C:\temp\SecurityData.csv
#I also want the Folder path, Size and SubFolder Count
}
#Step 4: Open in Excel
invoke-item -path C:\temp\SecurityData.csv
以下是我发现对这个主题有用的一些网站:http: //blogs.msdn.com/b/powershell/archive/2007/03/07/why-can-ti-pipe-format-table-to-export-csv -and-get-something-useful.aspx
http://www.maxtblog.com/2010/09/to-use-psobject-add-member-or-not/