Jump to content
  • 0

Identify Disconnected sessions then reboot VDIs

David Begbie1709163777




Looking to find a script that will help me temporarily before I fix this issue properly...


I need to identify all NP VDIs that have disconnected sessions running over 4 hours. Then I need to shut these VDIs down.


Identifying the VDIs with the target sessions is no problem but then invoking a power action is the bit I cant get.  Logging the session off is not an option, I need to shut each target machine down.


Thanks in advance!

Link to comment

4 answers to this question

Recommended Posts

  • 0

There you go, you can use the same logic without an export/import directly in your script to just pull the machines into an array, and then loop through the array


$Criteria = "Get your list of machines here"


then something like 


foreach ($computer in $Criteria) {
	write-host "computer Name is: $($computer.Name)"
	New-BrokerHostingPowerAction -Action TurnOff -MachineName $computer.Name


  • Like 1
Link to comment
  • 0
On 3/8/2023 at 11:01 PM, James Kindon said:

Thanks for the reply James.


New-BrokerHostingPowerAction -Action TurnOff -MachineName 'VDINamehere' works but switching the "TurnOff command to Shutdown doesnt.  I know I have a more serious problem with ghost sessions but just tryng to find a quick way to get on an even keel in terms of healthy user sessions and machines until I get a chance to upgrade the VDA etc.


Do you have an example of using PS to run this New-BrokerHostingPowerAction -Action TurnOff -MachineName 'VDINamehere' command against an list of VDIs in .txt or .csv?



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...