2017-05-26 19 views
1

私はローカルでこれを行う場合、私はすべての情報を取得する:取得プロセスの製品バージョンのリモートコンピュータを

get-process | select-object name,fileversion,company 

しかし、私はリモートコンピュータ上でそれを行う場合、私は唯一のプロセス名を取得し、他のすべてのフィールドがありますブランク。なぜ誰かが同じ情報を取得する方法を知っていますか?私はその情報にアクセスする必要があるので、私はドメイン管理者の資格情報を使用しています。

get-process -computername xcomp123 | select-object name,fileversion,company 
+1

私は同じことを見る。 'Invoke-Command -ComputerName xcomp123 -ScriptBlock {Get-Process} 'で必要な情報を得ることができます。オブジェクト名、ファイルバージョン、会社名を選択します。 (PS Remotingが設定されていると仮定します)。なぜそれがうまくいかないのかを見ると、.Netフレームワーク '[system.diagnostics.process] :: GetProcess()'とローカルプロセスの '' [system.diagnostics.process] :: GetProcess( 'xcomp123' ) 'を使用しているので、PowerShellの手の外にあるので、リモートでバージョンが返ってくるわけではありません。また、ローカルで 'gwmi win32_process'を実行した場合、バージョン情報は返されません。 – TessellatingHeckler

+0

実行可能パスのプロパティからその情報を派生させることができます。私は今すぐに時間がないので、私は更新を与えるでしょう。 – restless1987

答えて

0

あなたはこのソリューションを試すことができます。

$Computername = 'Remotehost' 

$Session = New-CimSession -ComputerName $Computername 

$process = Get-CimInstance -ClassName Win32_Process -CimSession $Session 

$col = New-Object System.Collections.ArrayList 

foreach ($n in $process){ 

    $exePath = $null 
    $ExeInfo = $null 

    $exePath = $n.ExecutablePath -Replace '\\','\\' 

    $ExeInfo = Get-CimInstance -ClassName Cim_DataFile -Filter "Name = '$exePath'" -ErrorAction SilentlyContinue 

    [void]$col.add([PSCustomObject]@{ 
     Name = $n.name 
     FileVersion = $ExeInfo.Version 
     Company = $ExeInfo.Manufacturer 
     PSComputername = $n.PSComputername 
    }) 
} 
Remove-Cimsession $session 
$col 

更新:

は、私は一つのプロセスだけをチェックするようにコードを削減しました。私はクライアントコンピュータ上のプロセスと同じ名前の参照ファイルをアサートします。あなたはあなたのニーズに合わせてそれを変更するかもしれません。

$computernameに複数のコンピュータを指定することができますので、コードを何度も何度も実行する必要はありません。

#region Reference file 

$RefFile = Get-item "\\x123\c$\program files\prog\winagent\file.exe" 

#endregion 

#region remote file 

[string[]]$Computername = 'Remotehost1', 'Remotehost2' 
$Processname = $RefFile.Name 

foreach ($n in $Computername) { 
    $Session = New-CimSession -ComputerName $n 
    $process = Get-CimInstance -ClassName Win32_Process -CimSession $Session -Filter "name = '$Processname'" 
    $exePath = $process.ExecutablePath -Replace '\\', '\\' 
    $ExeInfo = Get-CimInstance -ClassName Cim_DataFile -Filter "Name = '$exePath'" -ErrorAction SilentlyContinue 
    [PSCustomObject]@{ 
      Name   = $Processname 
      FileVersion = $ExeInfo.Version 
      Company  = $ExeInfo.Manufacturer 
      PSComputername = $n 
     } 
    Remove-Cimsession $session 
} 

#endregion 
+0

メモリ内のプロセスのバージョンとexeのファイルバージョンを比較して、それらが同じかどうかを確認しました。監視対象のサーバーにエージェントを送信するサーバー製品があります。ホスト・サーバーをアップグレードするときに、リモート・プロセスが最新であることを確認します。ここに私が書いたものがあります: $ a = invokecommand -computername x123 -scriptblock {get- process} | where-object -filterscript {$ _。名前のような "123"} |選択 - オブジェクトファイルのバージョン $ path = '\\ x123 \ c $ \ program files \ prog \ winagent \ file.exe' $ b =(dir $ path).versioninfo 比較オブジェクト$ a $ b – user445408

関連する問題