각 개체에 대한 루프를 통해 사용자 지정 개체를 CSV 형식의 텍스트 파일로 출력하려고합니다. 한 줄에 하나의 개체.Powershell 사용자 지정 추가 개체를 csv 파일
그러나 아무것도 파일에 기록되지 않습니다.
변환 할 형식이 있습니까? 먼저
$rechten = Get-ADGroupMember -Identity $v -Recursive -ERRORACTION silentlycontinue | Get-ADUser -Property DisplayName -ERRORACTION silentlycontinue | Select-Object Name
Write-Host -ForegroundColor Yellow "ADgroup $v wordt uitgevlooid."
foreach ($rechtenhouder in $rechten) {
$objResults = New-Object PSObject
$objResults | Add-Member -MemberType NoteProperty -Name DirectoryPath -Value $objPath
$objResults | Add-Member -MemberType NoteProperty -Name Identity -Value $rechtenhouder.name
$objResults | Add-Member -MemberType NoteProperty -Name Systemrights -Value $accessRight.FileSystemRights
$objResults | Add-Member -MemberType NoteProperty -Name systemrightstype -Value $accessRight.accesscontroltype
$objResults | Add-Member -MemberType NoteProperty -Name isinherited -Value $accessRight.isinherited
$objResults | Add-Member -MemberType NoteProperty -Name inheritanceflags -Value $accessRight.inheritanceflags
$objResults | Add-Member -MemberType NoteProperty -Name rulesprotected -Value $objACL.areaccessrulesprotected
$objResults | Add-Member -MemberType NoteProperty -Name Adtype -Value "User"
$arrResults += $objResults
Add-Content $exportpathtxtappend $objresults
}
을, 당신은 단지 $ objResult = 새-개체 psobject의 @ {DirectoryPath ='와 개체를 만들 수 있습니다 $ objPath; Identity = "and so on ...."}' – Clijsters
그리고'Add-Content'를 사용하지 마십시오. ['Export-CSV'] (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/export-csv?view=powershell-5.1)는 친구입니다. – Clijsters
가능한 원인으로 스크립트가 중단되면 파일에 이미 일부 출력이 있기 때문에 AC를 사용하고 싶습니다. – woef