I don’t know very much powershell. I have a simple question:
I have e environment with 40 virtual Windows Servers (2012R2, 2016 and 2019). Now I woll use a Powershellscript on one Server (Domaincontroller) who will put all installed updates on all servers. Limited to a period. An I will use a file (.txt or .csv) to set the servernames who I will check with this script.
Example: I will set the following in the script and then i can see all installed updates from a period only for this servers:
You really should not be using a domain controller for this. It should be done from an admin workstation/server.
You can use Get-Content to read the text file and then create a loop to get the hotfix information for each computer. You can pipe the output of Get-HotFix to Where-Object to filter the dates.
The problem is, at the end the .txt-file is empty. But when I add only one server in the comptuers.txt, then it works. Is there a limit? Or do I need a other code?
You are overwriting the text file each time the loop runs. Look at the help for Out-File and you should be able to work out how to append data to a file rather than overwriting it each time.