I have been writing snippets of code and testing them before i build a larger script.
Goal is to get a list of servers from my environment put it into a variable then use get-hotfix to read each of the server names in the variable and output a list of hotfixes on screen…
$Computers = Get-ADComputer -identity *
First step put all server names in $computer variable
Now run through loop
Foreach ($computer in $computers)
now open action block
{get-hotfix | select hotfixID, Description}
The challenge I am facing is nothing is output to screen. Spending hours trying to get this to work but I am hitting a dead wall.
Can someone please suggest ideas/thoughts ? perhaps I am going down the wrong path.
Please, when you post code format it as code using the code tags “PRE”. Thanks
When you use Get-ADComputer with the parameter -Identity you have to provide an existing unique identifier of a computer object in your AD. It can be a A distinguished name, a GUID (objectGUID), a security identifier (objectSid) or a Security Accounts Manager account name (sAMAccountName). If you want to collect a bunch of computers from your AD you will have to use the -Filter parameter with the asterisk “*”. But you should limit the search with the parameter -SearchBase to lower the stress you put on your AD to get this list.
Assuming not all of the computers in your network are reachable all the time you should check the connectivity before you try to query their hotfix status. Something like this could be a starting point:
You should always read the complete help including the examples for the cmdlets you’re about to use to learn how to use them and to learn what they are capable of.