我在Windows 10中有以下脚本工作,但不是在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
我已经以pipe理员身份运行Powershell_ISE,并设置了Set-ExecutionPolicy RemoteSigned。
我在Windows 10上得到的结果是:
10-09-2017_03-31-10 LLC @{ProcessorAffinity=63} LC @{ProcessorAffinity=63}
结果我越来越在Windows 7上:
10-09-2017_11-23-26 LLC LC
Get-Process似乎不适用于Windows Embedded Standard。 有没有其他的方式来做到这一点。
Get-Process | Format-Table ProcessorAffinity, *
即使在升级的PowerShell(ISE)中 ,我的标准Windows-8 / 64bit上的某些进程也显示为空的ProcessorAffinity。
而且, Process.ProcessName属性 (== Name AliasProperty )不包含.exe扩展名:
ProcessName属性包含不包含.exe扩展名或path的可执行文件名,如Outlook。 获取和操作与同一个可执行文件关联的所有进程是有帮助的。
PowerShell_ISE, 普通用户 :
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...
作为pipe理员的 PowerShell:
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...