Asnp Citrix.*
Add-PSSnapin VMware.VimAutomation.Core
$DDC = “DDC ServerName”
$VDI = “DomainName\VDI Name”
$DesktopGroup = “Desktop Group Name”
Step 3: Powershell Script to check the last connection time:
Asnp Citrix.*
$d = (Get-Date).AddDays(-60)
Get-BrokerDesktop -AdminAddress "$DDC" -DesktopGroupName "$DesktopGroup" -Filter { LastConnectionTime -le $d } | ft -a HostedMachineName,LastConnectionUser,LastConnectionTime,Protocol
Step 4: You need to enable maintenance mode of the VDI that you are planning to delete
Set-BrokerPrivateDesktop -AdminAddress "$DDC" -InMaintenanceMode $true -MachineName "$VDI"
Get-VM ‘MachineName’| Shutdown-VMGuest -Confirm:$false
New-BrokerHostingPowerAction -AdminAddress " $DDC" -MachineName " $VDI " -Action Shutdown
New-BrokerHostingPowerActi
Remove-BrokerMachine -AdminAddress "$DDC" -MachineName "$VDI” -DesktopGroup "$DesktopGroup" –Force
Remove-BrokerMachine -AdminAddress " $DDC " -MachineName "$VDI"
Remove-BrokerMachine - Removes one or more machines from a desktop group.
# Loading Snapins
Asnp Citrix.*
Add-PSSnapin VMware.VimAutomation.Core
#Declaring the Variables
$DDC = “DDC ServerName”
$VDI = “DomainName\VDI Name”
$DesktopGroup = “Desktop Group Name”
# Enable Maintenace Mode
Set-BrokerPrivateDesktop -AdminAddress "$DDC" -InMaintenanceMode $true -MachineName "$VDI"
#Shutdown the VM
New-BrokerHostingPowerAction -AdminAddress " $DDC" -MachineName " $VDI " -Action Shutdown
#Delete the VDI from the Desktop Group
Remove-BrokerMachine -AdminAddress "$DDC" -MachineName "$VDI” -DesktopGroup "$DesktopGroup" –Force
#Delete the VM from the Catalog
Remove-BrokerMachine -AdminAddress " $DDC " -MachineName "$VDI"
Tested Environment
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)