I am trying to use qwinsta and rwinsta with powershell code. When I try to run this I get an error "The term 'qwinsta' is not recognized as the name of a cmdlet, function, script file, or operable program." I need to be able to do this remotely on several machines without having to add any .dll's or modules to the other machines. I tried the Terminal Services Powershell Module, but you need to be able to put that on the remote machines and I am not able to do that.
Within powershell ISE how would I run qwinsta? I am not looking to parse the information just gather it. This is the following code I have tried (which I had found on this site also):
function Get-TSSessions {
param(
$ComputerName = "localhost"
)
qwinsta /server:$ComputerName |
#Parse output
ForEach-Object {
$_.Trim() -replace "\s+",","
} |
#Convert to objects
ConvertFrom-Csv
}
Get-TSSessions -ComputerName "localhost" | ft -AutoSize