locked
FilePath On Remote Machine RRS feed

  • Question

  • Hello,

    I want to find out if a running processor(Illustrator) on a remote machine is 64-bit or 32-bit.

    I found out a way of finding the path where the .exe is running - for example the path for

    32-bit = C:\Program Files (x86)\
    64-bit = C:\Program Files\

    Get-Process -ProcessName Illustrator -FileVersionInfo

    However, when I try do this on a remote machine:

    Get-Process -ComputerName DESKTOP01 -ProcessName Illustrator -FileVersionInfo

    I get this error:

    Get-Process : Exception getting "Modules" or "FileVersion": "This feature is not supported for remote computers.".
    At line:1 char:1
    + Get-Process -ComputerName desktop01 -ProcessName Illustrator -FileVersionInfo
    + 
        + CategoryInfo          : InvalidOperation: (System.String[]:String[]) [Get-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.GetProcessCommand
    

    Can I please have a little help on this? Or is there another way to do it?

    Kind regards,

    Sam Colman

    Monday, March 10, 2014 12:06 PM

Answers

  • Hi Sam,

    Here's a method you can use to check the path of the remote process, since Get-Process doesn't return that info for remote machines:

    $processName = 'ILLUSTRATOR.EXE'
    $computerToCheck = 'DESKTOP01'
    
    $processInfo = Get-WmiObject -Class Win32_Process -Filter "Name = '$processName'" -ComputerName $computerToCheck
    
    If ($processInfo.Path -like '*\Program Files (x86)\*') { 
    
        Write-Host "$processName is 32-bit"
    
    }
    
    Else { Write-Host "$processName is 64-bit" }

    This only checks for \Program Files (x86)\ to determine if the process is x86/x64, so this isn't very robust.


    Don't retire TechNet! - (Don't give up yet - 12,700+ strong and growing)

    • Marked as answer by Samc56198489 Monday, March 10, 2014 4:47 PM
    Monday, March 10, 2014 3:42 PM

All replies

  • Give that a try (don't know from where I got this snippet, but it's still in my library):

    [System.Diagnostics.Process[]] $processes64bit = @()
    [System.Diagnostics.Process[]] $processes32bit = @()
    foreach($process in get-process) {
        $modules = $process.modules
        foreach($module in $modules) {
            $file = [System.IO.Path]::GetFileName($module.FileName).ToLower()
            if($file -eq "wow64.dll") {
                $processes32bit += $process
                break
            }
        }
        if(!($processes32bit -contains $process)) {
            $processes64bit += $process
        }
    }
    write-host "32-bit Processes:"
    $processes32bit | sort-object Name | format-table Name, Id -auto
    write-host ""
    write-host "64-bit Processes:"
    $processes64bit | sort-object Name | format-table Name, Id -auto

    Under 64bit machines it works fine

    I've changed the line

    foreach($process in get-process) {

    to

    foreach($process in get-process -COMPUTERNAME TestServer1) {

    where TestServer1 is a 2008R2. Script was called from within a Windows 7 x64.

    • Edited by Peter Ziganki Monday, March 10, 2014 2:59 PM Additional infos
    • Proposed as answer by Peter Ziganki Monday, March 10, 2014 2:59 PM
    Monday, March 10, 2014 1:08 PM
  • Hi Sam,

    Here's a method you can use to check the path of the remote process, since Get-Process doesn't return that info for remote machines:

    $processName = 'ILLUSTRATOR.EXE'
    $computerToCheck = 'DESKTOP01'
    
    $processInfo = Get-WmiObject -Class Win32_Process -Filter "Name = '$processName'" -ComputerName $computerToCheck
    
    If ($processInfo.Path -like '*\Program Files (x86)\*') { 
    
        Write-Host "$processName is 32-bit"
    
    }
    
    Else { Write-Host "$processName is 64-bit" }

    This only checks for \Program Files (x86)\ to determine if the process is x86/x64, so this isn't very robust.


    Don't retire TechNet! - (Don't give up yet - 12,700+ strong and growing)

    • Marked as answer by Samc56198489 Monday, March 10, 2014 4:47 PM
    Monday, March 10, 2014 3:42 PM
  • Hello,

    I have modified Mike's script to suit my needs a little better.

    However, you are able to type in any random name, when you search for the process. Then it returns as 64-bit when it's not even running. OR show the full process name with extension? Then I have to type it in like for like? but I prefer the first option.

    $computer = Read-Host "Please enter computer name"
    
    Get-Process -ComputerName $computer | Sort-Object WS | select -Property ProcessName
    
    $processName = Read-Host "Please enter process name"
    
    $processInfo = Get-WmiObject -Class Win32_Process -Filter "Name = '$processName'" -ComputerName $computer
    
    If ($processInfo.Path -like '*\Program Files (x86)\*') { 
    
        Write-Host "$processName is 32-bit"
    
    }
    
    Else { Write-Host "$processName is 64-bit" }

    Kind regards,

    Sam Colman

    Monday, March 10, 2014 4:37 PM
  • Hello,

    Don't worry! Got it!

    I used this when getting process info:

    Get-WmiObject -Class Win32_Process -ComputerName $computer | Sort-Object WorkingSetSize | select -Property ProcessName

    Kind regards,

    Sam Colman

    Monday, March 10, 2014 4:47 PM