請可有人告訴我如何在我下面的腳本中使用PowerShell的GET-qadcomputer + WMI查詢
***Get-QADComputer -LdapFilter "(operatingsystem=*server*)"***
。 (我可以得到它與它只是失敗的get-qadcomputer位的文本文件工作)
***function inventory {
PROCESS {
$os = gwmi win32_operatingsystem -comp $_
$cs = gwmi win32_computersystem -comp $_
$obj = new-object psobject
$obj | add-member noteproperty Name $os.csname
$obj | add-member noteproperty RebootDate $os.ConvertToDateTime($os.LastBootUpTime)
$obj | add-member noteproperty Manufacturer $cs.manufacturer
$obj | add-member noteproperty Model $cs.model
$obj | add-member noteproperty Operating_System $os.caption
$obj | add-member noteproperty Architecture $os.OSArchitecture
$obj | add-member noteproperty Service_Pack $os.ServicePackMajorVersion
write-output $obj
}
}
gc C:\scripts\lastreboot\syn_pc.txt -ErrorAction SilentlyContinue | inventory | Export-Csv c:\scripts\lastreboot\inventory2.csv***
管道我認爲Get-QADComputer在您發佈的代碼中不起作用的主要原因是代碼中沒有Get-QADComputer。 –
對不起,也許我不清楚,當我取代gc C:\ scripts \ lastreboot \ syn_pc.txt --ErrorAction默默繼續與我把它放在第一位失敗 – user1767744