Stéphane Thirion
  • Home
  • Consulting – Raidho
  • homelab
3K
0
0
Stéphane Thirion
Stéphane Thirion
  • Home
  • Consulting – Raidho
  • homelab
  • Citrix
  • Microsoft
  • PowerShell
  • Windows 10
  • Windows 2008
  • Windows 2008 R2
  • Windows 2012
  • Windows 2012R2
  • Windows 2016
  • Windows 7
  • Windows 8
  • XenApp
  • XenDesktop

Remotely clean up Virtual Machines drives – XenDesktop

  • April 4, 2016
  • Stephane Thirion
Total
0
Shares
0
0
0
0
0
0
0

Following up the previous blogs XenDesktop XenApp 7.x – vmware / ad / delivery group notes and descriptions sync and Expand virtual machines hard disk – automation and continue in automated task, I had to clean up the D: drive of different XenDesktop Delivery Group. As there was no security restriction on the D: drive some users used it as a repository for some of their project… That caused some issues :

  • Users complain of losing their working data from a session to another (pooled VDI, new logon = new vm)
  • Some disk space notification where displayed to random users…
  • Calls where raise to the helpdesk support team

Beside hiding the D: drive to avoid non necessary access (ie : non system access) check this blog to do so : Citrix XenApp – Hiding system drives part 1/2 an automated task had to be performed to “clean” this D: drive

The variable $XDDC is the FQDN of a Delivery Controler, $Exclusion is the files and folder you want to exclude from being removed.

For example : the directories “logs” “pvsvm” “System Volume Information” “$RECYCLE.BIN” and the files “dedicateddumpfile.sys” “pagefile.sys” and “vdiskdif.vhdx” will be ignore from the delete process. Most of these files and directory are system protected anyway it’s more to avoir error during script execution.

Once you have a clear list of what you need and want to keep you can proceed to the next step.

 

Cleanup.ps1   
Add-PSSnapin citrix*
 
$XDDC = "XDDCFQDN:80"
$Exclusion = "logs", "pvsvm", "System Volume Information", "$RECYCLE.BIN", "dedicateddumpfile.sys", "pagefile.sys", "vdiskdif.vhdx"
 
foreach ($list in (Get-BrokerMachine  -AdminAddress $XDDC -Filter "((SessionSupport -eq `"SingleSession`" -and DesktopGroupName -eq `"VDI`"))" -Skip 0 | Select-Object HostedMachineName)) {
 
$list.HostedMachineName = $list.HostedMachineName.Insert(0,'')
$list.HostedMachineName += "d$"
 
# Write-Host $list.HostedMachineName
 
 
   Get-ChildItem -Path $list.HostedMachineName -Exclude $Exclusion | foreach ($_) {
       "CLEANING :" + $_.fullname
       Remove-Item $_.fullname -Force -Recurse -Verbose
       "CLEANED... :" + $_.fullname 
 
  } 
 
}

This script will clean everything which is not in the $Exclusion list so be careful when you run the script. This script assume all the targeted VM are switched ON of course.

Leave a comment bellow if you have an idea how to improve this script !

Total
0
Shares
Tweet 0
Share 0
Share 0
Share 0
Share 0
Share 0
Share 0
Related Topics
  • automation
  • clean
  • hard drive
  • PowerShell
  • script
  • XenApp
  • XenDesktop
Stephane Thirion

Previous Article
  • Citrix
  • Microsoft
  • Provisioning Services
  • Scripting
  • VMware
  • vSphere
  • Windows 7
  • Windows 8
  • XenApp
  • XenDesktop

Expand virtual machines hard disk – automation

  • March 30, 2016
  • Stephane Thirion
View Post
Next Article
  • Citrix
  • Microsoft
  • PowerShell
  • Scripting
  • Windows 10
  • Windows 2008 R2
  • Windows 2012
  • Windows 2012R2
  • Windows 2016
  • Windows 7
  • Windows 8
  • XenApp
  • XenDesktop

Set acls remotely to a VDI / RDSH Delivery Group

  • April 5, 2016
  • Stephane Thirion
View Post
You May Also Like
View Post
  • Citrix
  • CTP
  • Uncategorized

This is the end of an era

  • Stephane Thirion
  • February 16, 2022
View Post
  • VMware
  • vSphere
  • Windows 2022

Migrating FSMO roles Windows 2022 Server

  • Stephane Thirion
  • January 3, 2022
View Post
  • ADC
  • Experience
  • Linux

Cloud yes but no, thanks (there is some Citrix)

  • Stephane Thirion
  • December 7, 2021
View Post
  • Azure
  • Azure
  • PowerShell
  • Scripting
  • Security

Export all Admin Roles and members from Azure AD

  • Rodolphe Herpeux
  • March 25, 2021
View Post
  • RDS
  • Security
  • Windows 2016

RDS access to applications with second authentication factor by smartcard

  • Rodolphe Herpeux
  • January 7, 2021
View Post
  • Windows 2016
  • Windows 2019

Migration farm ADFS operating system Windows server 2016 to Windows server 2019

  • Rodolphe Herpeux
  • January 6, 2021
View Post
  • Windows 2016

Migrate ADFS configuration Database from WID to MS-SQL

  • Rodolphe Herpeux
  • January 5, 2021
View Post
  • ArchY.net Site
  • Azure
  • Citrix
  • Cloud
  • Experience
  • Microsoft
  • News
  • Office365
  • Raidho
  • VMware

Mettre en place une solution de travail à distance (RemoteOffice / Remoteworking) 2/2

  • Stephane Thirion
  • March 24, 2020
vmware
Blog Stats
  • 1,229,422 hits
Categories
  • Amazon (1)
  • Apple (20)
    • iOS (5)
    • Mac OSx (11)
  • ArchY.net Site (30)
  • Azure (8)
  • Certifications (3)
  • Citrix (207)
    • ADC (1)
    • Citrix Virtual Apps and Desktops (3)
    • NetScaler (12)
    • Password Manager (3)
    • Personal vDisk (5)
    • Power and Capacity Management (3)
    • Provisioning Services (22)
    • Receiver (29)
    • ShareFile (8)
    • Single Sign On (3)
    • SmartAuditor (2)
    • Storefront (12)
    • Synergy (25)
    • User Profile Management (2)
    • VDI (7)
    • WebInterface (21)
    • XenApp (84)
    • XenApp Plugin (3)
    • XenClient (10)
    • XenDesktop (55)
    • XenServer (42)
  • Cloud (12)
  • Crystal Ball (2)
  • CTP (13)
  • Docker (2)
  • Events (35)
    • E2E – PubForum (9)
    • Geek Speak (3)
  • Experience (51)
  • Kubernetes (2)
  • Licensing (3)
  • Linux (11)
  • Microsoft (145)
    • Azure (8)
    • Office365 (4)
    • PowerShell (18)
    • RDS (5)
    • Windows 10 (6)
    • Windows 2003 (21)
    • Windows 2008 (20)
    • Windows 2008 R2 (54)
    • Windows 2012 (13)
    • Windows 2012R2 (13)
    • Windows 2016 (18)
    • Windows 2019 (4)
    • Windows 2022 (1)
    • Windows 7 (27)
    • Windows 8 (19)
    • Windows Virtual Desktop (1)
    • Windows XP (11)
  • News (5)
  • Raidho (2)
  • Raspberry (2)
  • Scripting (13)
  • Security (4)
  • Slide Deck (1)
  • Thin Clients (3)
  • Twitter (1)
  • Ubiquiti (1)
  • Uncategorized (12)
  • VMware (26)
    • VMWare WorkStation (2)
    • vSphere (14)
Stéphane Thirion
Don't Follow the Trend

Input your search keywords and press Enter.