I am looking to run a script on a remote machine using an automation tool that runs the scripts in the system context.
What I have so far:
$userId = Get-Process -IncludeUserName explorer | % username | sort Username -Unique
Write-Host $userid.ToLower()
Results:
Get-Process : A parameter cannot be found that matches parameter name 'IncludeUserName'. At line:1 char:39 + $userId = Get-Process -IncludeUserName <<<< explorer | % username | sort Username -Unique + CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand ToLower : You cannot call a method on a null-valued expression. At line:2 char:27 + Write-Host $userid.ToLower <<<< () + CategoryInfo : InvalidOperation: (ToLower:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Any ideas how to help this script? Or the cause of the errors?