0
서버의 모든 폴더에 대한 폴더 정보 및 보안 정보를 가져 오려고합니다. 하지만 Powershell에 익숙하지 않습니다. 초보자를 돕는 마음?여러 명령을 CSV 파일로 파이프하는 방법 [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-t-i-pipe-format-table-to-export-csv-and-get-something-useful.aspx
http://www.maxtblog.com/2010/09/to-use-psobject-add-member-or-not/
그래서 PSobject는 해시 테이블 데이터 형식입니까? –
도움을 다시 한번 감사드립니다! –
PSObject를 사용하여 사용자 지정 개체를 만들 수 있습니다. 즉, 개체에 속성과 메서드를 추가 할 수 있습니다. 또한 레코드 또는 구조체를 만드는 방법으로 생각할 수도 있습니다. –