script to pull Os version on multiple computers need for meltdown

hi all

i am looking for a power shell script to pull the os version on our 5000 servers in our environment. i need to call the servers list from a text file. and require output on csv file.

script should say access denied in case of credentials does not work. also if server is down should say "Not online".

please help. needed this urgently for meltdown vul. fix.
Venkatesan TAssociate ConsultantAsked:
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.

Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
There's a way that came out yesterday afternoon to install a module to check if this vulnerability is affected a system. I have created this article:
https://www.experts-exchange.com/articles/31438/Intel-Bug-Spectre-and-MeltDown.html

$computers = Get-Content "computers.txt"
$sb={
    Install-Module SpeculationControl
    Get-SpeculationControlSettings
}
foreach($computer in $computers){
   $comp= Invoke-Command -ComputerName computer -ScriptBlock $sb
  add-content -path "C:\log.txt" -value "$computer,$comp" 
}

Open in new window

Venkatesan TAssociate ConsultantAuthor Commented:
but now I need to know the running os version and need a result in csv file for multiple computers.pls help.
MilesLoganCommented:
This will get you the OSVersion but will not chekc if they are online or if you have access ... at least you can start with this for now .

Import-Module ActiveDirectory
Get-Content Users.txt | Get-ADComputer -Properties name,OperatingSystem,OperatingSystemVersion | Select-Object name,OperatingSystem,OperatingSystemVersion | Export-Csv ServerOS.csv -NoTypeInformation

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
Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I've just posted PS code to do the complete check for the domain at https://www.experts-exchange.com/questions/29076942/Meltdown-patch-Checker-script-for-remote-PCs.html#a42426331. This would also work with a text file with a few simple changes.
Venkatesan TAssociate ConsultantAuthor Commented:
no... i really don't want at this point meltdown patch os installed or mot.

my environment has mix of windows 2003, 2008, 2008 R2, 2012 and 2012 R2. microsoft has released patch for only 2008 R2 and 2012 R2. for the rest , registry fix can be applied. so i need get installed os of all my servers.  i preference the server names passe from text file because we have many desktop like windows 10 also connected to domain.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Miles script should work for you. It just asks AD for the details, and so machines do not need to be online, and no credentials issues can arise.
Venkatesan TAssociate ConsultantAuthor Commented:
many thanks it worked perfectly.
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.