Pulling my hair out

Hello All,

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.


Best wishes





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:

$SearchBase = 'OU=Computers,OU=SampleDepartement,OU=SampleSite,OU=SampleRegion,DC=SampleCompany,DC=com'
$ComputerList = Get-ADComputer -SearchBase $SearchBase -Filter * 

foreach($ComputerName in $ComputerList.Name){
    if(Test-Connection -ComputerName $ComputerName -Count 1 -Quiet){
        Get-HotFix -ComputerName $ComputerName

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.

Olaf your assistance again is once more appreciated. You are really helping to fill gaps in my knowledge when it comes to Powershell.