$arrayHold = @($readFile)
$array = @()
$arrayHold[0]
for ($i = 0; $i -lt $arrayHold.Length; $i++) {
$OSversion = Invoke-Command -ComputerName $arrayHold[$i] -ScriptBlock {
Get-WMIObject Win32_OperatingSystem -ComputerName $arrayHold[$i]
} | Select-Object Caption
# create a nested for loop and throw the OSVERSION into it then nest the $i
# for loop.
#if ($OSversion -match "7") {
$invcmd = Invoke-Command -ComputerName $arrayHold[$i] -ScriptBlock {
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1
} | Select-Object PSComputerName, SMB1 | Format-Table -AutoSize
#$printInfo = $OSversion + $invcmd
$array += $invcmd
#}
}
$array | Out-File $save\"$file"
我将主机名从文件传递到数组中。
我收到的错误是:
空数组
目标是检索操作系统版本并根据用户操作的操作系统版本推出更新。
编辑:
它与$OSversion
变量有关。我把它拿出来并且没有空数组错误。