Thursday, May 20, 2010

gotta be a better way...

So I'm starting to learn powershell by the seat of my pants and my trusty friend google. All I was trying to go was get the file versions to verify a hotfix was installed.

Doing it this way I had to do some replace string in the results of fullnames. without it, it parsed out looking like {@fullname=\\blah\C$\windows\system32} causing the fileversion to fail.

Got a better idea, post it and let me know...

$a = Get-childitem -path "\\SomServer\C$\windows\system32" -recurse -include "Afd.sys","Dns.exe","Dnsperf.dll","Dnsperf.h","Dnsperf.ini","Mswsock.dll","Tcpip.sys","Tcpip6.sys","W03a3409.dll"|Select-Object fullname
$a=$a|ForEach-Object {$_ -replace "FullName=","" }
$a=$a|ForEach-Object {$_ -replace "@{",""}
$a=$a|ForEach-Object {$_ -replace "}",""}
$a|ForEach-Object{[System.Diagnostics.FileVersionInfo]::GetVersionInfo($_)|Select-Object FileName,ProductVersion}

No comments:

Post a Comment