Out-File에 내 열이 모두 표시되지 않습니다.

Out-File에 내 열이 모두 표시되지 않습니다.
Get-ADComputer -SearchBase "DC=some,DC=website,DC=net" -Filter * -Properties Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion | Sort Description | Format-Table Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap  | Out-File $env:USERPROFILE\Desktop\AD-Quick-Inventory.txt

위의 코드는 내가 원하는 것이지만 .txt 파일로 출력하면 5개의 열만 있습니다(설명에서 멈춤).

모든 열이 표시되도록 하려면 어떻게 해야 합니까?

내보내기-csv를 시도했는데 내가 원하는 데이터를 내보냈지만 내가 선택하지 않은 임의의 속성도 여러 개 내보냈습니다.

답변1

특정 cmdLet은 파이프라인 끝(Format-table, Out-File, Import-Csv)에서만 사용할 수 있습니다. 해당 cmdLets 중 하나를 사용하면 전자가 개체 데이터를 문자열 등과 같은 비 개체 데이터로 변환했기 때문에 다른 것을 추가하면 정크가 생성됩니다. format-table로 바꾸면 select-object선택한 속성만 포함된 CSV를 얻게 됩니다. select-object.

Get-ADComputer -SearchBase "DC=some,DC=website,DC=net" -Filter * `
-Properties Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion `
| Select-Object -Property Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion `
| Sort Description | `
Export-Csv -Path AD-Quick-Inventory.csv -NoTypeInformation

답변2

다음과 같이 Get-ADComputer를 csv로 파이프하는 것은 어떻습니까?

Get-ADComputer -SearchBase "DC=some,DC=website,DC=net" -Filter * `
-Properties Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion `
| Select-Object -Property Name,Created,whenChanged,LastLogonDate,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion `
| Sort Description   | ConvertTo-CSV -NoTypeInformation | Out-File $path 

관련 정보