好的,所以我一直在工作一两天的脚本。我对Powershell非常陌生,但学习速度很慢。我已经整理了购买的脚本。基本上,我唯一需要做的就是从林中所有远程服务器上获取NIC模型或描述。接近1k。该脚本当前有效,但是每个主机名或IP输出4次。
我在这里做错了什么?这是脚本。
看来您有更多的问题,然后又重复了。您正在循环FILEPATH(char array,$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'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句