簡體   English   中英

Powershell腳本的輸出無法正常工作?

[英]Output of powershell script not working correctly?

好的,所以我一直在工作一兩天的腳本。 我對Powershell非常陌生,但學習速度很慢。 我已經整理了購買的腳本。 基本上,我唯一需要做的就是從林中所有遠程服務器上獲取NIC模型或描述。 接近1k。 該腳本當前有效,但是每個主機名或IP輸出4次。

我在這里做錯了什么? 這是腳本。

http://pastebin.com/D3qfmyX1

看來您有更多問題,然后重復了。 您正在循環FILEPATH(char數組, $ipaddresses )。

嘗試這樣的事情:

$infile = Read-Host 'What is the path of your call file (absolute path, ex. "c:\test\file.txt")?'
$servers = Get-Content $infile
$outfile = Read-Host -Prompt 'Please specify the path at which you would like ot save your file. (CSV)'
New-Item $outfile -ItemType File -Force

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $servers | Select-Object PSComputerName, Description | 
Export-Csv $outfile -NoTypeInformation -Delimiter ";"

Invoke-Item $outfile
Read-Host -Prompt 'Your file has been saved at your destination, Good bye'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM