-1

My script is very simple but only works for ADMIN users:

Get-Process -Name Firefox-IncludeUserName

UserName Field appears as blank if I run it as normal user the and it is the reason of why I'm looking for help.

I tried to run it inside Invoke-Command as below to try make it run with elevate rights but still is giving me the same results.

$AdsName = "username"

$AdsPassword = "76492d1116743f0423413b16050a5345MgB8AFoAbAAvAEQAUQA4AEEAeABGADUAawA3ADYAcwAxAG0AbQAxAGEAQQA0AGcAPQA9AHwANgA0ADQAYgBiAGMANABhADAAOABjADQAYwBiADgAYwA1ADMAMgA4AGYAMwAwADQAZAA1ADcANgA0AGMAZgA5ADkAOQBlADUAMQA1ADMAYwA5ADAAOAA5ADgAYgAwADMAOAB =" | ConvertTo-SecureString -Key (1..16)

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdsName, $AdsPassword

$server = $env:computername

$results = Invoke-Command -Computer $server -Credential $cred -ScriptBlock {
                Get-Process -Name Firefox -IncludeUserName } |
                Select Username, ProcessName | Sort Username

$total_text = "Total Accubuild connections: " + @($results).count

Write-Output $results

Write-Output ""

Write-Output "----------------------------------"

Write-Output $total_text

Result:

UserName ProcessName
-------- -----------
         Firefox 
         Firefox 
         Firefox 
----------------------------------
Total Firefox connections: 3

Thanks in advance for any help.

RamPc
  • 1
  • 1

0 Answers0