0
Import-Module ActiveDirectory
$computers = Get-ADComputer -Filter * -SearchBase "OU=workstations,DC=company,DC=org" |
Select-Object -Expand Name
$wmiObjs = Get-WmiObject -Class Win32_ComputerSystem -Property Name, Model -ComputerName $computers |
select Name, Model |
Export-Csv c:\temp\workstations-models.csv
我收到錯誤,如下面,我想已經放置到CSV以及與TXT它來與PC名稱:如何編寫異常細節,以CSV
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At line:3 char:12 + $wmiObjs = Get-WmiObject -Class Win32_ComputerSystem -Property Name, ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
即使有幾種代碼樣式的PoSh,我會建議在花括號之前放置空格。 – Clijsters