powershell help with script to get hotfix information get-hotfix

I have this script, and it gets most of the info I need, I would like it to also return the name of the system the hotfix is on.

$kbpatch = Read-Host "enter the KB patch here"
$servers = get-content servers.txt
$servers | foreach { get-hotfix -id $kbpatch -computername $_  | select HotFixID,InstalledOn }

This returns this:
HotFixID                                                    InstalledOn
--------                                                         -----------
KB132456                                              10/23/2015 12:00:00 AM

I need the system name in there also, but my failed efforts so far have not worked.

Thank you as always!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Include the PsComputerName property.
$servers | foreach { get-hotfix -id $kbpatch -computername $_  | select HotFixID,InstalledOn,pscomputername }

Open in new window

SquigglyMonkeyAuthor Commented:
Nope, thanks for responding, but that didn't display the system name. I also  tried $_, computername, systemname, pscomputername.  none displayed the system name, .
FOXActive Directory/Exchange EngineerCommented:
make sure you
1. open powershell (run as administrator)
2 run the command            import-module activedirectory
3. use CN in the script to get the computername
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

FOXActive Directory/Exchange EngineerCommented:
$servers | foreach { get-hotfix -id $kbpatch -computername $_  | select HotFixID,InstalledOn,CN }
Jose TorresSenior SQL Server DBACommented:
Works for me

PS H:\> $kbpatch = 'KB2862152'
$servers = @("YBCCC01", "YBCCC02")
$servers | foreach { get-hotfix -Id $kbpatch -ComputerName $_ | select HotFixID,InstalledOn,PsComputerName }

HotFixID                                        InstalledOn                                    PSComputerName                                
--------                                        -----------                                    --------------                                
KB2862152                                       11/14/2013 12:00:00 AM                         YBCCC01                                       
KB2862152                                       11/14/2013 12:00:00 AM                         YBCCC02      

Open in new window

David Johnson, CD, MVPOwnerCommented:
$kbpatch = Read-Host "enter the KB patch here"
$servers = get-content servers.txt
foreach ($server in $servers) {
$hotfix = get-hotfix -id $kbpatch -computername $server
write-host $server $hotfix.HotFixID $hotfix.InstalledOn

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SquigglyMonkeyAuthor Commented:
Thanks, that works perfect.
SquigglyMonkeyAuthor Commented:
Jose, I don't know why that does not work for me, but it does not display the name, but thanks for responding.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.