【发布时间】:2017-02-27 21:19:05
【问题描述】:
我目前正在编写一个脚本,该脚本应该通过主机名和 ip 查询机器。
$IP = (get-content "C:\Users\me\Desktop\PowerShell\ips.txt")
$hostname = (get-content "C:\Users\me\Desktop\PowerShell\hostnames.txt")
现在我需要将$IP 和$hostname 插入到一个字符串中。
write-host "This is my $IP, this is my $hostname"
到目前为止,我尝试使用 for 循环并在每个循环中递增 I,但不是只从我的 txt 文件中插入一个,而是全部插入。
for ($i=0; $i -lt 1; $i++ )
我怎样才能使我的循环从一个文件中获取一行,从另一个文件中获取一行?
【问题讨论】:
-
这个问题做得更多,但你要找的设置是一样的。
标签: loops powershell foreach powershell-5.0