Skip to content

Instantly share code, notes, and snippets.

@mendel129
Last active December 24, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendel129/6809704 to your computer and use it in GitHub Desktop.
Save mendel129/6809704 to your computer and use it in GitHub Desktop.
Get a list of all server 2003, connect to them, and get the filversion of a specific dll, create a list and export it to a csv
#get a list from ad with all windows server 2003 and 2003 r2 machines
$list= get-ADComputer -Filter {OperatingSystem -Like "Windows Server*2003*"}
#intantiate an empty array
$hashlist=@{}
$admin=get-credential
#connect to each computer, get the file, and select it's version
foreach($computer in $list){
$answer = Get-WMIObject -Computer $computer.DNSHostName -credential $admin -Query "SELECT * FROM CIM_DataFile WHERE Drive ='C:' AND Path='\\windows\\system32\\' AND FileName='crypt32' AND Extension='dll'" | select Version
#create a hashlist
$hashlist[$computer]=$answer
}
$hashlist | export-csv export.csv
#rewrite the hashlist for proper export to a csv-file (otherwise, it's almost not readable for humans :-)
$collection = @()
foreach ($key in $hashlist.Keys) {
$store = "" | select "OS","count"
$store.OS = "$Key"
$store.count = $hashlist.$Key
$collection += $store
}
$collection | Export-Csv "OSCount2.csv" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment