问题从文件中获取数据和在脚本中使用 [英] Issue Getting Data from File and Using in Script

查看:48
本文介绍了问题从文件中获取数据和在脚本中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


以下是我试图整理一个脚本来读取远程PC上的补丁:



  $ computer   =   gc env    computername 
$ computers
= get - 内容 - path c \ computer txt
$ csvfile
= " c:\\\
ame.csv"

foreach $ computer in $ computers { 获取 - WmiObject - Class WIN32_QuickFixEngineering | 选择 - Object " Caption" " CSName" " Description" " InstalledBy" " InstalledOn" | ConvertTo - HTML | Out - 文件 $ csvfile }





我得到了结果,但是我从本地计算机而不是远程计算机上得到它们。我在尝试从c:\ computer获取计算机名称时做错了什么.txt文件?





再次感谢您的帮助。

解决方案

您需要使用-Co​​mputerName参数Get-WmiObject。


http://ss64.com /ps/get-wmiobject.html


Here is what I got trying to put together a script to read the patches on a remote PC:

$computer = gc env:computername
$computers= get-content -path c:\computer.txt
$csvfile = "c:\name.csv"
foreach ($computer in $computers) {Get-WmiObject -Class WIN32_QuickFixEngineering | Select-Object "Caption","CSName","Description","InstalledBy","InstalledOn" |ConvertTo-HTML | Out-File $csvfile}


I do get the results, but I get them from the local machine and not the remote one. What am I doing wrong trying to get the computer name from the c:\computer.txt file?

Thanks again for the help.

解决方案

You need to use the -ComputerName parameter of Get-WmiObject.

http://ss64.com/ps/get-wmiobject.html


这篇关于问题从文件中获取数据和在脚本中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆