|
Replies:
12
-
Pages:
1
-
Last Post:
Nov 26, 2009 9:04 AM
by: Shay Levy
|
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
File version over the network
Posted:
Nov 25, 2009 7:43 AM
|
|
|
Hello,
Is it possible to get the version of a file of a remote computer?
Do I have to use "Get-Wmiobject"?
Thank you very much Fabrizio.
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 1:20 AM
in response to: Shay Levy
|
|
|
Does ".versioninfo" and / or "fl" require that Powershell has a newer version than 1.0?
|
|
|
Posts:
436
Registered:
12/15/08
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 3:20 AM
in response to: fabrigatti
|
|
|
Yes, you need PowerShell v2.
/chris
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 6:10 AM
in response to: Shay Levy
|
|
|
I have improved the script like this (basing on Chris suggestion from another thread):
# ping-host function function ping-host ($server, [int] $timeout = 7000){ $ping = gwmi Win32_PingStatus -filter "Address='$($server)' and timeout=$($timeout)" $ping = $ping | Add-Member -passThru -force -memberType NoteProperty -name "StatusText" -value "" switch ($ping.statusCode){ 0 {$ping.StatusText = "Success"}11001 { $ping.StatusText = "Buffer Too Small"} 11002 {$ping.StatusText = "Destination Net Unreachable"}11003 { $ping.StatusText = "Destination Host Unreachable"} 11004 {$ping.StatusText = "Destination Protocol Unreachable"}11005 { $ping.StatusText = "Destination Port Unreachable"} 11006 {$ping.StatusText = "No Resources"}11007 { $ping.StatusText = "Bad Option"} 11008 {$ping.StatusText = "Hardware Error"}11009 { $ping.StatusText = "Packet Too Big"} 11010 {$ping.StatusText = "Request Timed Out"}11011 { $ping.StatusText = "Bad Request"} 11012 {$ping.StatusText = "Bad Route"}11013 { $ping.StatusText = "TimeToLive Expired Transit"} 11014 {$ping.StatusText = "TimeToLive Expired Reassembly"}11015 { $ping.StatusText = "Parameter Problem"} 11016 {$ping.StatusText = "Source Quench"}11017 { $ping.StatusText = "Option Too Big"} 11018 {$ping.StatusText = "Bad Destination"}11032 { $ping.StatusText = "Negotiating IPSEC"} 11050 {$ping.StatusText = "General Failure"} default {$ping.StatusText = "Unknown"} } $ping } get-content "C:\PCCheck.txt" | foreach{ # $_ If ((ping-host $_).statusText -eq "Success"){
$unc = "\\$_\c$\Program Files\Mobiliti\Unplugged\MNUAGENT.exe" $_ [System.Diagnostics.FileVersionInfo]::GetVersionInfo($unc) | fl ProductName,ProductVersion }
Else {
"$_ not reachable" | Write-Host
}
} Below you can find some of the resultsI get. When the execution of the script encounter a PC for which the credentials are insufficient (or for which the browsing would result as "Logon Failure: The target account name is incorrect"), I get the following (ref. the bottom part):
XDREOE001
ProductName : Network/Unplugged ProductVersion : 4, 7, 0, 0
XDREOE002 not reachable
XDREOE003 Exception calling "GetVersionInfo" with "1" argument(s): "\\XDREOE003\c$\program files\mobiliti\unplugged\bin\MNUAGENT.exe" At :line:74 char:53 + [System.Diagnostics.FileVersionInfo]::GetVersionInfo <<<< ($unc) | fl ProductName,ProductVersion
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 6:34 AM
in response to: Shay Levy
|
|
|
Yes, the error terminates the script. No more computers are processed after it.
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 7:03 AM
in response to: Shay Levy
|
|
|
Adding a trap the script continues. Good!
How should I set an IF condition which shows "Machinename not browsable" whenever the trap lets the script continue?
If trap??? {
"$_ not browsable" | Write-Host
}
Thanks Fabrizio.
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 7:53 AM
in response to: fabrigatti
|
|
|
Try with this (remove the else clause):
if ((ping-host $_).statusText -eq "Success"){ $computer =$_
trap { write-warning "$computer not reachable" } $unc = "\\$_\c$\Program Files\Mobiliti\Unplugged\MNUAGENT.exe" [System.Diagnostics.FileVersionInfo]::GetVersionInfo($unc) | select ProductName,ProductVersion }
|
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
|
|
Posts:
30
Registered:
10/1/09
|
|
|
|
Re: File version over the network
Posted:
Nov 26, 2009 8:45 AM
in response to: Shay Levy
|
|
|
At first unreachable machine, this is what I get:
WARNING: RESOLS001 not browsable Exception calling "GetVersionInfo" with "1" argument(s): "\\RESOLS001\c$\program files\mobiliti\unplugged\bin\MNUAGENT.exe" At :line:78 char:53 + [System.Diagnostics.FileVersionInfo]::GetVersionInfo <<<< ($unc) | fl ProductName,ProductVersion
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|