Change root password XenServer pool

I have just finished creating a PowerShell script that changes the local root password for a Citrix XenServer pool.

You will find a ZIP file containing the script here: http://muya.no-ip.info/wordpress/wp-content/uploads/2011/09/Change-root-Password-XenServer.zip

 

Script:

function Get-EncryptedText($text) {

$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($text)

$result = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)

[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr)

$result

}

Try {

Get-PSSnapin XenServerPSSnapin -ErrorAction Stop

}

Catch [Exception] {

If ($env:PROCESSOR_ARCHITECTURE -eq “AMD64”) {Invoke-Expression “$env:systemroot\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe ‘c:\Program Files (x86)\Citrix\XenServerPSSnapIn\XenServerPSSnapIn.dll'”; Add-PSSnapin XenServerPSSnapin}

If ($env:PROCESSOR_ARCHITECUTRE -eq “x86”){Invoke-Expression “$env:systemroot\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe ‘c:\Program Files\Citrix\XenServerPSSnapIn\XenServerPSSnapIn.dll'”; Add-PSSnapin XenServerPSSnapin}

}

 

$PoolMaster = Read-Host ‘Enter Poolmaster’

$Username = Read-Host ‘Enter Username’

$Password = Read-Host -AsSecureString ‘Enter Old Password’

$NewPassword = Read-Host -AsSecureString ‘Enter New Password’

$NewPasswordPlain = Get-EncryptedText $NewPassword$

PasswordPlain = Get-EncryptedText $Password

 

# // Build connection to xenserver

 

Try {

$Connect = [XenAPI.Session] ($(“https://” + $PoolMaster))

$Connect = Connect-XenServer -Server $PoolMaster -UserName $Username -Password $PasswordPlain -NoWarnCertificates

}

 

Catch [XenAPI.Failure] {

$Connect = Connect-XenServer -Server ($($_.exception.ErrorDescription[1])) -UserName $Username -Password $Password -NoWarnCertificates

}

 

# // Change Password

$Connect.change_password($PasswordPlain, $NewPasswordPlain)

XenDesktop 5 Maintenance Script

I’ve just finished creating a XenDesktop 5 Maintenance Script in PowerShell. Currently running tests to run the script on the Controllers through SCCM.

What the script does (in a nutshell):

  1. Connect to XenServer
  2. Start the VM
  3. Update the virus definition files
  4. Update the App-V cache
  5. Shutdown the VM
  6. Make a new snapshot
  7. Update the VDI’s to use the new snapshot.

Let’s wait and see….