Hi guys,
I have created a simple script to collect the hot fix in a list of 4 computers in a text file. But when running the script, only the first computer in the list appear 4 times as below
Blockquote
PS C:> $computers = Get-Content -Path c:\test\computers.txt
PS C:> $computers | ForEach-Object {Get-hotfix | sort -Descending | select -First 5 | ft -a}
Source Description HotFixID InstalledBy InstalledOn
Server1 Security Update KB5003638 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB5001402 NT AUTHORITY\SYSTEM 24/06/2021 00:00:00
Server1 Security Update KB4550994 NT AUTHORITY\SYSTEM 04/06/2020 00:00:00
Server1 Security Update KB4535680 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB4520724 NT AUTHORITY\SYSTEM 22/01/2020 00:00:00
Source Description HotFixID InstalledBy InstalledOn
Server1 Security Update KB5003638 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB5001402 NT AUTHORITY\SYSTEM 24/06/2021 00:00:00
Server1 Security Update KB4550994 NT AUTHORITY\SYSTEM 04/06/2020 00:00:00
Server1 Security Update KB4535680 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB4520724 NT AUTHORITY\SYSTEM 22/01/2020 00:00:00
Source Description HotFixID InstalledBy InstalledOn
Server1 Security Update KB5003638 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB5001402 NT AUTHORITY\SYSTEM 24/06/2021 00:00:00
Server1 Security Update KB4550994 NT AUTHORITY\SYSTEM 04/06/2020 00:00:00
Server1 Security Update KB4535680 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB4520724 NT AUTHORITY\SYSTEM 22/01/2020 00:00:00
Source Description HotFixID InstalledBy InstalledOn
Server1 Security Update KB5003638 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB5001402 NT AUTHORITY\SYSTEM 24/06/2021 00:00:00
Server1 Security Update KB4550994 NT AUTHORITY\SYSTEM 04/06/2020 00:00:00
Server1 Security Update KB4535680 NT AUTHORITY\SYSTEM 25/06/2021 00:00:00
Server1 Security Update KB4520724 NT AUTHORITY\SYSTEM 22/01/2020 00:00
Blockquote
The computers.txt looks as below:
Server1
Server2
Server3
Server4
Is there anything wrong with the format of the text file? Does it need a comma between computers?