I am trying to type the following:
$a = get content myfile.txt
$a | foreach (get-hotfix -computername $_ | sort installedon)[-1]
what am I doing wrong?
if I type:
(get-hotfix -computername thename | sort installedon)[-1]
works great
sorry if dump question, just begining.
/s/ Frank in Florida
ForEach-Object takes (at least) one ScriptBlock parameter, and ScriptBlocks have curly braces around them (which are missing in your code). You also appear to be missing a hyphen in the Get-Content cmdlet. For example:
Get-Content -Path MyFile.txt | ForEach-Object { Get-Hotfix -ComputerName $_ | Sort-Object InstalledOn }