Search found 9 matches
- Mon Nov 04, 2019 2:11 pm
- Forum: PowerShell
- Topic: quser.exe works in console and ISE but not in service
- Replies: 9
- Views: 7866
Re: quser.exe works in console and ISE but not in service
QUSER is used to get RDS sessions and is not used for local sessions but does return the console session. Azure AD is used to get Azure accounts and does not give sessions. Here is an example of how to use quser in PowerShell: https://gallery.technet.microsoft.com/scriptcenter/Get-LoggedOnUser-Gath...
- Mon Nov 04, 2019 2:08 pm
- Forum: PowerShell
- Topic: quser.exe works in console and ISE but not in service
- Replies: 9
- Views: 7866
Re: quser.exe works in console and ISE but not in service
I created a bounty on StackOverflow, the issue was very silly and nothing to do with the service or service permissions. It was to do with the service being a 32-bit process on a 64-bit system. There is not a quser.exe in C:\Windows\SysWOW64 but you can work around this on a 64-bit OS by running C:\...
- Mon Nov 04, 2019 7:29 am
- Forum: PowerShell
- Topic: quser.exe works in console and ISE but not in service
- Replies: 9
- Views: 7866
Re: quser.exe works in console and ISE but not in service
Thanks! I ended up going with this one: $QUserToRichObject = ((Invoke-Expression "$env:windir\system32\quser.exe") -replace '\s{2,}', ',' | ConvertFrom-Csv) This is the only part I cannot get working, my service is almost complete and I can't believe the only thing I'm having issues with i...
- Fri Nov 01, 2019 10:14 am
- Forum: PowerShell
- Topic: quser.exe works in console and ISE but not in service
- Replies: 9
- Views: 7866
Re: quser.exe works in console and ISE but not in service
Hey, thanks for coming back to me. This makes sense, I'll see what I can do!
Also, this wouldn't work, as the output wouldn't be written to the variable:
$output = Start-Process "$env:windir\system32\quser.exe" -NoNewWindow
Also, this wouldn't work, as the output wouldn't be written to the variable:
$output = Start-Process "$env:windir\system32\quser.exe" -NoNewWindow
- Thu Oct 31, 2019 10:09 am
- Forum: PowerShell
- Topic: quser.exe works in console and ISE but not in service
- Replies: 9
- Views: 7866
quser.exe works in console and ISE but not in service
I have the following function in one of my service scripts, it gets the user sessions on the local device using quser.exe, collects more information for each user account from Get-LocalUser and then returns an array of objects containing the desired user information. When I run this function in the ...
- Mon Oct 28, 2019 5:40 am
- Forum: PowerShell
- Topic: PowerShell service not stopping as expected
- Replies: 5
- Views: 4430
Re: PowerShell service not stopping as expected
The issue was being caused by an Object Event Registration. $null = Register-ObjectEvent $Job -EventName StateChanged -Action { if ($eventArgs.JobStateInfo.State -eq [System.Management.Automation.JobState]::Completed){ Receive-JobDataOnFinish -JobID $Sender.Id $eventSubscriber | Unregister-Event -Fo...
- Fri Oct 25, 2019 4:47 pm
- Forum: PowerShell
- Topic: PowerShell service not stopping as expected
- Replies: 5
- Views: 4430
Re: PowerShell service not stopping as expected
This is really cheeky of me (try not to judge too harshly) but the service doesn't need to stop gracefully, it just needs to stop ;) Are you aware of a method of terminating the service regardless? A hard, mean and reliable method of 'killing and closing' everything? If not, would you mind elaborati...
- Fri Oct 25, 2019 4:19 pm
- Forum: PowerShell
- Topic: PowerShell service not stopping as expected
- Replies: 5
- Views: 4430
Re: PowerShell service not stopping as expected
Hey, thanks for taking the time to help me with this! Are you referring to the snippet below? If so it was added by PowerShell Studio. $CountDown = 61 # Maximum wait for loop to exit while($global:bServiceRunning -and $Countdown -gt 0) { Start-Sleep -Seconds 1 # wait for your main loop to exit $Coun...
- Fri Oct 25, 2019 2:40 pm
- Forum: PowerShell
- Topic: PowerShell service not stopping as expected
- Replies: 5
- Views: 4430
PowerShell service not stopping as expected
I have created a service using PowerShell Studio 2019, it simply loops through the creation and collection of jobs that query the local system. All of the jobs take just a few seconds to complete, and I have utilise Register-ObjectEvent to detect the state change of every job, allowing me to collect...