$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"
I am passing host names from a file into an array.
The error I am receiving is:
Null Array
The goal is to retrieve the OS version and push out an update according to whichever OS version the user is operating on.
EDIT:
It has something to do with the $OSversion
variable. I take it out and there isn't a null array error.