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!
LVL 3
SquigglyMonkeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

footechCommented:
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

FOXActive Directory/Exchange EngineerCommented:
$servers | foreach { get-hotfix -id $kbpatch -computername $_  | select HotFixID,InstalledOn,CN }
Jose TorresCertified Database AdministratorCommented:
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
Powershell

From novice to tech pro — start learning today.