Don't use localhost.
No idea how you are using remoting.
This works just fine for me:
Invoke-Command {qwinsta} -computername ws702
Close process which isn't invoked by Current Logged-in user
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Abhishek_Paul
- Posts: 24
- Last visit: Fri Jun 15, 2018 2:04 am
Re: Close process which isn't invoked by Current Logged-in user
Why make it so complicated. Just use Invoke and loop it on $computers.
Code: Select all
$computers |
ForEach-Object{
$activeuser = Invoke-Command -ScriptBlock { qwinsta } -computername $_ |
Select-String 'active' |
ForEach-Object{
$_.Line.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries)[1]
}
[pscustomobject]@{
ComputerName = $_
ActiveUser = $activeuser
}
} # | Export-Csv <file>
- Abhishek_Paul
- Posts: 24
- Last visit: Fri Jun 15, 2018 2:04 am
Re: Close process which isn't invoked by Current Logged-in user
Hi Jvierra,
As usual, you are the champ
With little modification, it worked for me.I appreciate your help.
Thanks a zillion.
As usual, you are the champ
With little modification, it worked for me.I appreciate your help.
Thanks a zillion.