If I try to run this script with Get-ChildItem which means dir this script works perfectly, but If I try to run this command Get-RDUserSession, my script has the following error message:
This command runs perfectly in PowerShell admin and I get back the values
Get-RDUserSession -ConnectionBroker broker.local | sort Username
Or you can try this command as well
Get-Command Get-RDUserSession
If I run the above mentioned command this runs perfectly in PowerShell but
Get-Command : The term 'Get-RDUserSession' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
https://powershelladministrator.com/2015/12/01/get-logged-on-users-and-sessions/
Hope these help.