Unidesk 3.0 Script to Increase UEP Size for Persistent Desktops



Similar documents
Windows Server 2008 R2: Server Management and PowerShell V2

ISCSI Server Installation

Integration Guide: Using Unidesk 3.x with Citrix XenDesktop

Microsoft Windows PowerShell v2 For Administrators

Microsoft IT Camp Hands-On Lab

AddLocalUser AddLocalGroup AddLocalUserToLocalGroup AddDomainUserToLocalGroup AddDomainGroupToLocalGroup

Add User to Administrators Group using SQL Lookup Table

User Experience Reference Design

Good Morning Wireless! SSID: MSFTOPEN No Username or Password Required

Automating Microsoft

Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p.

Click Studios. Passwordstate. Password Discovery, Reset and Validation. Requirements

Windows Server 2012 R2 Storage Infrastructure

Microsoft. Jump Start. M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0

How To - Implement Single Sign On Authentication with Active Directory

Guide to deploy MyUSBOnly via Windows Logon Script Revision 1.1. Menu

Using DSC with Visual Studio Release Management

EXAM Installing and Configuring Windows Server Buy Full Product.

A layman s guide to PowerShell 2.0 remoting. Ravikanth Chaganti

CAPIX Job Scheduler User Guide

DESLock+ Basic Setup Guide Version 1.20, rev: June 9th 2014

Windows Command-line Automation Techniques for Dell EqualLogic PS Series Arrays

Secure Messaging Server Console... 2

You Should Be Using PowerShell Aaron Kaiser Senior Technology Support Specialist Parkway School District

CDP-H210 Introduction to Azure Active Directory

Deployment Guide: Unidesk and Hyper- V

Acronis Backup & Recovery 11

Step by Step Guide to Deploy Microsoft LAPS

Acronis Backup & Recovery 10 Advanced Server Virtual Edition. Quick Start Guide

Forefront Management Shell PowerShell Management of Forefront Server Products

Managing View with PowerCLI

The safer, easier way to help you pass any IT exams. Exam : Installing and Configuring Windows Server 2012 R2.

Implementing and Managing Windows Server 2008 Hyper-V

Installation Manual (MSI Version)

Outline SSS Microsoft Windows Server 2008 Hyper-V Virtualization

Updating Your Windows Server 2008 Technology Skills to Windows Server 2008 R2

Tool Tip. SyAM Management Utilities and Non-Admin Domain Users

Troubleshoot Using Event Log Mining

Installing and Configuring Windows Server 2012

PowerShell for Exchange Admins

Installing and Configuring Windows Server 2012

Installation Manual v2.0.0

6422: Implementing and Managing Windows Server 2008 Hyper-V (3 Days)

Upgrading Your Skills to MCSA Windows Server 2012

STATISTICA VERSION 12 STATISTICA ENTERPRISE SMALL BUSINESS INSTALLATION INSTRUCTIONS

Installing and Configuring Windows Server 2012

Installing and Configuring Windows Server 2012

MCSA Server (Exam )

Upgrading Your Skills to MCSA Windows Server 2012

Installing and Configuring Windows Server 2012 MOC 20410

Lync Server Patching Guide

HOW TO SILENTLY INSTALL CLOUD LINK REMOTELY WITHOUT SUPERVISION

Microsoft. Jump Start. M11: Implementing Active Directory Domain Services

Managing Windows Environments with Group Policy

ADFS 2.0 Application Director Blueprint Deployment Guide

NIIT Education and Training, Doha, Qatar - Contact: /1798;

Enterprise Self Service Quick start Guide

Netwrix Auditor. Virtual Appliance Deployment Guide. Version: 8.0 8/1/2016

Build Your Knowledge!

Course 20410: Installing and Configuring Windows Server 2012

This module explains how to configure and troubleshoot DNS, including DNS replication and caching.

Active Directory Deployment and Management Enhancements

Installing and Configuring Login PI

DEPLOYMENT GUIDE DEPLOYING F5 AUTOMATED NETWORK PROVISIONING FOR VMWARE INFRASTRUCTURE

RSA Authentication Manager 8.1 Virtual Appliance Getting Started

Acronis Backup & Recovery 11.5 Quick Start Guide

SQL Server 2008 R2 Express Edition Installation Guide

Implementing Multi-machine Monitoring

Preparing a Windows 7 Gold Image for Unidesk

How to Create a Delegated Administrator User Role / To create a Delegated Administrator user role Page 1

Deploying Windows Server 2008 Course 6418C; 3 days, Instructor-led

Virtual Dashboard for VMware and Hyper-V

Backing Up CNG SAFE Version 6.0

Exam : Installing and Configuring Windows Server 2012

Extending Remote Desktop for Large Installations. Distributed Package Installs

Server & Workstation Installation of Client Profiles for Windows

Deploying Personal Virtual Desktops by Using RemoteApp and Desktop Connection Step-by-Step Guide

How To Set Up Egnyte For Netapp Sync For Netapp

Installation Instruction STATISTICA Enterprise Small Business

Exam : Administrating Windows Server 2012 R2. Course Overview

Virtual Appliances. Virtual Appliances: Setup Guide for Umbrella on VMWare and Hyper-V. Virtual Appliance Setup Guide for Umbrella Page 1

ESX System Analyzer Version 1.0 Installation Guide

Intel vpro Technology Module for Microsoft* Windows PowerShell*

MS Installing and Configuring Windows Server 2012

How to monitor AD security with MOM

20410: Installing and Configuring Windows Server 2012

Upgrading Your Skills to MCSA Windows Server 2012

Accops HyWorks v2.5. Quick Start Guide. Last Update: 4/18/2016

Windows Clients and GoPrint Print Queues

Administration Guide. . All right reserved. For more information about Specops Gpupdate and other Specops products, visit

Hyperoo 2.0 A (Very) Quick Start

In order to upload a VM you need to have a VM image in one of the following formats:

NovaBACKUP Virtual Dashboard

Autograph 3.3 Network Installation

Introduction to Windows Server 2016 Nano Server

Installing and Configuring Windows Server 2012

aims sql server installation guide

Foglight. Foglight for Virtualization, Free Edition Installation and Configuration Guide

DeployStudio Server Quick Install

Administering Windows Server 2012

Transcription:

Unidesk 3.0 Script to Increase UEP Size for Persistent Desktops Summary When creating a desktop the size of the Personalization Layer (UEP) is defined in GB for the desktop. There are two vhdx files that make up the UEP both set to this size. One is for Application files and Settings; the other is for user data. They are start out the last two disks attached to the desktop but when more layers are added they can then be in any volume on the desktop. The Path to the UEP files is always under the CP appliance folder\unidesklayers\users. See below. This script can be used to increase the size of the UEP disks. The script uses The Hyper-V PowerShell Cmdlets to increase the VHDX size. It then using PowerShell Remoting with DiskPart scripts to extend the volume in Windows. Version 1.0 February 28, 2015 Page 1

Restrictions The following restriction should be kept in mind: 1. This applies to Unidesk 3.x systems only (Hyper-V), do not use on Unidesk 2.x 2. The desktop must be running when the script is run, therefore if desktops are actively being REBIC ed ensure that the desktops you are running the script against are not in the list of those being rebuilt. 3. This script only works on Persistent Desktops. Non-Persistent Desktops must be recreated. Requirements 1. The Hyper-V Module is required on the machine the script is run from 2. Administrator Access to HyperV is required 3. Administrative Access to the desktops is required 4. The Desktops must have WINRM enabled, running and configured. This is best done through GPO. Setting up the script Make sure the script is not blocked. Check its properties and unblock if necessary. Copy the script into a folder. Edit the script appropriately. At the top of the script there is a section where variables are defined as shown below. Each of these settings must be configured for your environment. Note: the script can be run by entering a lits of desktops in the $Destops array as shown below. The script will also check for a Desktops.txt file in the folder the script is run from. If that file is found the script will load desktops from the file and use the file only and not the setting below. The file should have only the desktop name one per line. # Define Variables #Enter one or more Desktops in an array. #If Desktops.txt is found in the script directory the desktops to update will be loaded from Deskotps.txt rather than this setting. $Desktops = @("persistentrds5") #Enter the Size in GB that the desktop will be i.e if you want the UEP to be 10 GB use 10 $SizeinGB = 15 #Enter vcenter Server FQDN. You will be prompted for credentials $HyperVServer = "hyperv2.zylowski.com" #Enter Admin User and password on Windows Desktops $GuestUser = "zylowski\rzylowski" $GuestPassword = "password" The $Desktops array can have as many desktops defined as needed. Just separate the desktops with a coma and put quotes around them. The $size in GB is the size the script sets the UEP to. So if you want the UEP to be 20 GB and it is currently 5 GB you enter 20. Version 2.0 April 20, 2012 Page 2

Running the script Run PowerShell and change directories to the script folder. Make sure you have previously run the following command to allow scripts to run on this system or run it now Set-ExecutionPolicy Remote Signed Then run the script by typing>.\growuephv.ps1 Or you can use the PowerShell ISE or any other PowerShell Editor. The script will output lots of information as it runs, it will also create a log in the script folder. The upgrade here was from 4 to 10 GB. The script #Script Developed by Rob Zylowski, Unidesk Corporation #Version 1.0 10-5-2012 #This script can be used to increase the size of the Personalization Layer for Unidesk Persistent Desktops #The desktops should be running and the user can even be logged on #The script requires the HyperV module be installed on your workstation and WinRM running and configured on the desktops function Get-ScriptDirectory $Invocation = (Get-Variable MyInvocation -Scope 1).Value Split-Path $Invocation.MyCommand.Path Function LogLine($strLine) write-host $strline $global:logoutput += "$strline `n" #This may generate an error if its already loaded so we will clear the error cache $Error.Clear() # Define Variables Version 2.0 October 12, 2012 Page 3

#Enter one or more Desktops in an array. #If Desktops.txt is found in the script directory the desktops to update will be loaded from Deskotps.txt #rather than this setting. $Desktops = @("persistentrds5") #Enter the Size in GB that the desktop will be i.e if you want the UEP to be 10 GB use 10 $SizeinGB = 15 #Enter vcenter Server FQDN. You will be prompted for credentials $HyperVServer = "hyperv2.zylowski.com" #Enter Admin User and password on Windows Desktops $GuestUser = "zylowski\rzylowski" $GuestPassword = "password" # MAIN SCRIPT #If Desktops.txt exists use it for the source desktops $ScriptSource = Get-ScriptDirectory $mydatetime = Get-Date -Format MM-dd-yyyy-HHmmss $global:logfile = "$ScriptSource\GrowUEP-$myDateTime.txt" LogLine "--------------------------------------------------" Logline "Running Hyper-V Extend Unidesk UEP Disks Script" LogLine "--------------------------------------------------" if (Test-Path "$ScriptSource\Desktops.txt") $Desktops = Get-Content -Path "$ScriptSource\Desktops.txt" $count = $Desktops.Count Logline "Desktops.txt file found with [$count] desktops to extend" else $count = $Desktops.Count Logline "Desktops.txt file NOT found will use desktop list defined in script" Logline "Ther are [$count] desktops to extend" #Load HyperV module Logline "Importing Module HyperV" Import-Module Hyper-V $Capacity = 1024*1024*1024*$SizeinGB Logline "Disk Capacity will be set to [$SizeinGB] GB" Logline "--------------------------------------------------" Logline "" #Run the process for each MM in the Desktops Array foreach ($MM in $Desktops) Logline "Processing Desktop [$MM]" #Get the list of hard drives for the virtual machine $CurrentVM = Get-VM -Name $MM -ComputerName $HyperVServer $GetAllHds = Get-VHD -VMId $CurrentVM.id -ComputerName $HyperVServer #For each hard disk see if its a UEP disk by looking at the path. If it has a /User/ in the path its a UEP. foreach ($s in $GetAllHds) If ($s.path -like "*\User\*") $myuepdisk = $s.path logline "$myuepdisk is a UEP Disk, Resizing to [$Capacity] GB" Resize-VHD -Path $s.path -ComputerName $HyperVServer -SizeBytes $Capacity Else # $s.path + " is Not a UEP Disk" if (!($?)) Version 2.0 April 20, 2012 Page 4

Logline "HyperV Extend Disk failed skipping this desktop [$MM]" continue #Get the disk name using regex $regex = [regex]"([^\\]+)$" $VMDK = [regex]::match($s.path, $regex).groups[1] #Get the prefix using regex $regex = [regex]"^(.*?)\..*" $UEPPrefixFull = [regex]::match($vmdk, $regex).groups[1] $UEPPrefixFullString = "$UEPPrefixFull" $UEPPrefix = $UEPPrefixFullString.substring(0,6) #Now use POwershell remoting to extend the volume size on the desktop. Logline "Running Extend Job on Remote Computer..." $output = Invoke-Command -ComputerName $MM -ScriptBlock param ($UEPPrefix) #Get the disks using LIST DISK command NEW-ITEM name LISTVOLUMES.TXT itemtype file force OUT-NULL ADD-CONTENT path LISTVOLUMES.TXT LIST VOLUME $LISTDISKS=(DISKPART /S LISTVOLUMES.TXT) NEW-ITEM name EXTENDVOLUME.TXT itemtype file force OUT-NULL foreach ($VOL in $LISTDISKS) if ($VOL.length -ne 0) if ($VOL.length -gt 31) $volumestring = $VOL.substring(24,7).trim() if (($volumestring -ne "") -and ($volumestring -ne "------") -And ($volumestring -ne "on 6.3") -And ($volumestring -ne "Micros") -And ($volumestring -ne "BOOT")) if ($volumestring -eq $UEPPrefix) $volumeid = $vol.substring(8,3).trim() write-host "UEP Volume Found:" $volumestring "volumeid: $volumeid" write-output "UEP Volume Found:" $volumestring "volumeid: $volumeid `n" #Get the size to extend the disk NEW-ITEM name GETDISKS.TXT itemtype file force OUT-NULL ADD-CONTENT path GETDISKS.TXT RESCAN ADD-CONTENT path GETDISKS.TXT SELECT VOLUME $volumeid ADD-CONTENT path GETDISKS.TXT LIST DISK $GETDISKS=(DISKPART /S GETDISKS.TXT) foreach ($DISK in $GETDISKS) if ($DISK.length -ne 0) if ($DISK.substring(0,1).trim() -eq "*") $DiskID = $DISK.substring(6,3).trim() write-host "Disk ID: $DiskID" write-output "Disk ID: $DiskID `n" $ExtendSize = $DISK.substring(36,5).trim() $SizeMetric = $DISK.substring(41,2).trim() write-host "Metrix Sized Used: $SizeMetric" write-host "Metrix Sized Used: $SizeMetric `n" [int]$intextendsize = [convert]::toint32($extendsize, 10) if($sizemetric -eq "GB") $intextendsize = $intextendsize*1024 Version 2.0 October 12, 2012 Page 5

if (Test-Path EXTENDVOLUME.TXT)Remove-Item EXTENDVOLUME.TXT write-host "Extend Size: $intextendsize MB" write-output "Extend Size: $intextendsize MB `n" write-host "Extending Disk Size By : $intextendsize MB" write-output "Extending Disk Size By : $intextendsize MB `n" ADD-CONTENT path EXTENDVOLUME.TXT SELECT VOLUME $volumeid ADD-CONTENT path EXTENDVOLUME.TXT EXTEND SIZE=$intExtendSize ADD-CONTENT path EXTENDVOLUME.TXT DETAIL DISK $RemoteOutput = $EXTENDTVOL=(DISKPART /S EXTENDVOLUME.TXT) write-host "List Disk Output After Extend Operation" write-output "List Disk Output After Extend Operation `n" write-host "" write-output "`n" write-host "$RemoteOutput" write-output "$RemoteOutput `n" write-host "Removing working files.." write-output "Removing working files.. `n" Remove-Item EXTENDVOLUME.TXT -Confirm:$false Remove-Item GETDISKS.TXT -Confirm:$false Remove-Item LISTVOLUMES.TXT -Confirm:$false write-host "-------------------------------------------------------" write-output "------------------------------------------------------- `n" write-host "" write-output "`n" -ArgumentList $UEPPrefix Logline "" $RunningOutput += $global:logoutput $RunningOutput += $output $global:logoutput = "" $RunningOutput Out-file -FilePath $global:logfile -Encoding ASCII -Append Version 2.0 April 20, 2012 Page 6