I am creating a script on how to list all the disconnected sessions that are running for 4 hrs but the code does not work.
Get-XASession | Select ServerName, State, Accountname, Browsername | where {$_.State -eq "Disconnected", $_.Duration -eq "4 hr"}
No error message is showing and not results as well.
But when I run:
Get-XASession | Select ServerName, State, Accountname, Browsername | where {$_.State -eq "Disconnected"}
It is working.
Need some help here. Thanks.
You're not specifying an operator between your two conditions, instead you have a comma. Change your code to this:
You can see this at play with this code:
vs
I've answered your question directly above. Here's something that you may want to try though, it should (hopefully) return all sessions older than 4 hours old (I don't have access to these cmdlets so it's a best guess)