我對PHP,Javascript等非常熟悉,但我是Powershell的新手。我試圖從活動目錄中的所有計算機獲取IP地址和Mac地址。我遇到了一個腳本,獲得一個具有所有計算機名稱的對象,並通過foreach循環列出它們。在該循環中,我試圖運行以下命令:如何將對象的屬性轉換爲Powershell中的字符串
$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "root\CimV2" `
comp $objComputer.name -filter "IpEnabled = TRUE"
很顯然,這是行不通的,因爲它不能從管道取數據。是否需要使用名稱屬性並將其轉換爲在Get-WmiObject中使用的字符串變量?我試過用$ objComputer.name作爲值聲明一個字符串變量,並嘗試使用$($ objComputer.name),但對我而言也沒有。任何幫助將不勝感激。
@Joey只是想知道爲什麼你刪除這個:謝謝,並有一個很好的。 ? – Matt
馬特:[看看強大的Meta](http://meta.stackexchange.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts)。 – Joey