1

I have the following script work in windows 10 but not on windows 7:

$LogTime = Get-Date -Format "MM-dd-yyyy_hh-mm-ss"
$Path1= "TEST\TESTLog_$(get-date -f yyyy-MM-dd).txt"
$AffPBS= Get-Process "LLCService.exe" | Select-Object ProcessorAffinity
$AffLC= Get-Process "LCService.exe" | Select-Object ProcessorAffinity
$AffinityLLCFinal = "LLC  " + $AffPBS
$AffinityLCFinal = "LC   " + $AffLC
$FinalOutput = $LogTime+"  " +$AffinityLLCFinal +"     " + $AffinityLCFinal 
$FinalOutput | Out-File -Append $Path1

I have run the Powershell_ISE as administrator and also set Set-ExecutionPolicy RemoteSigned.

The results I'm getting on Windows 10:

10-09-2017_03-31-10  LLC  @{ProcessorAffinity=63}     LC   @{ProcessorAffinity=63}

THe results I'm getting on Windows 7:

10-09-2017_11-23-26  LLC       LC  

It seems like the Get-Process isn't working on Windows Embedded Standard. Is there any other way of doing this.

user75464
  • 183

1 Answers1

1
Get-Process | Format-Table ProcessorAffinity, *

shows empty ProcessorAffinity for some processes on my standard Windows-8/64bit even in elevated PowerShell (ISE).

Moreover, Process.ProcessName Property (== Name AliasProperty) does not include the .exe extension:

The ProcessName property holds an executable file name, such as Outlook, that does not include the .exe extension or the path. It is helpful for getting and manipulating all the processes that are associated with the same executable file.

Examples

PowerShell_ISE, regular user:

PS D:\PShell> (Get-Process * | 
    Select-Object Name, ProcessorAffinity) | 
        Group-Object -Property ProcessorAffinity | 
            Format-Table -AutoSize                    # merely for better readability

Count Name Group
----- ---- ----- 
   41      {@{Name=afwServ; ProcessorAffinity=}, @{Name=AppleMobileDeviceService; Proces...
   28 3    {@{Name=avgui; ProcessorAffinity=3}, @{Name=avguix; ProcessorAffinity=3}, @{N...

PowerShell as administrator:

PS C:\Windows\system32> (Get-Process * |
>>     Select-Object Name, ProcessorAffinity) |
>>         Group-Object -Property ProcessorAffinity |
>>             Format-Table -AutoSize                    # merely for better readability

Count Name Group
----- ---- -----
   10      {@{Name=afwServ; ProcessorAffinity=}, @{Name=aswidsagenta; ProcessorAffinity...
   59 3    {@{Name=AppleMobileDeviceService; ProcessorAffinity=3}, @{Name=avgsvca; Proc...
JosefZ
  • 1,639