From beaeddba5972421f13b7cd4beea8e057e8a6992a Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Fri, 15 Jul 2016 13:53:25 -0700 Subject: [PATCH] Rename Sysprep_Automation_Script_v1a.ps1 to Sysprep_Automation_Script.ps1 --- Scripts/Sysprep_Automation_Script.ps1 | 113 ++++++++++++++++++++++ Scripts/Sysprep_Automation_Script_v1a.ps1 | Bin 8282 -> 0 bytes 2 files changed, 113 insertions(+) create mode 100644 Scripts/Sysprep_Automation_Script.ps1 delete mode 100644 Scripts/Sysprep_Automation_Script_v1a.ps1 diff --git a/Scripts/Sysprep_Automation_Script.ps1 b/Scripts/Sysprep_Automation_Script.ps1 new file mode 100644 index 0000000..56b633d --- /dev/null +++ b/Scripts/Sysprep_Automation_Script.ps1 @@ -0,0 +1,113 @@ + +<#================================================== + Generated On: 6/27/2014 2:49 PM + Generated By: Brian Graf + VMware Technical Marketing Engineer - Automation + Organization: VMware + vCenter Sysprep File Transfer +================================================== +-------------------------------------------------- +==================USAGE=========================== + This script has been created to aid users who + upload multiple sysprep files to vCenter Server. + The upload button in vCenter only allows a single + file per upload. This script will allow the user + to upload as many files as they please. +-------------------------------------------------- +===============REQUIREMENTS======================= + Fill in the environment variables below. There + Is a $DefaultVIServer and a $target_vcenter. + This is because some customers may be running + their target vCenter server within a different + vCenter environment. + + On your local machine, you will need a directory + that includes the following folders: + * 2k + * svr2003-64 + * svr2003 + * xp + * 1.1 + * xp-64 + + Place all sysprep files within their respective + folders. + + Run the script. The script will determine if + the target_vCenter is a Windows VM or VCSA + and place the files accordingly. + + ***NOTE*** This script will give an error if + it tries to upload a filename that already exists + in the vCenter directory. If you wish for the + script to overwrite any file with the same name + add '-force' to the end of the copy-vmguestfile + command. +-------------------------------------------------- +#> + +# ---------------------------------------- +# USER CONFIGURATION - EDIT AS NEEDED +# ---------------------------------------- +$DefaultVIServer = "vcsa.lab.local" +$vCUser = "root" +$vCPass = "VMware1!" +$target_vcenter = "VCSA" +$target_vcenter_user = "root" +$target_vcenter_password = "VMware1!" +$Location = "C:\temp" +$vC_Partition = "C:" +# ---------------------------------------- +# END USER CONFIGURATION +# ---------------------------------------- + +# Sysprep Folders on vCenter +$folders = @("2k","svr2003-64","svr2003","xp","1.1","xp-64") + +# Add PowerCLI Snapin +Add-PSSnapin vmware.vimautomation.core + +# Connect to vCenter +connect-viserver $DefaultVIServer -user $vCUser -password $vCPass + +# Get view of the vCenter data +$myVC= get-vm $target_vcenter | get-view + +# $OS captures the Operating System Name +$OS = $myVC.config.GuestFullName + +# Switch of Operating System +switch -wildcard ($OS) +{ +# As per the compatibility guide, all OS's from the compatibility guide have been added +"*SUSE*" {Write-Host "This is a SUSE Machine" -ForegroundColor Green; $OS = "VCSA"} +"* XP *" {Write-Host "This is a Windows XP Machine" -ForegroundColor Green} +"* 2003 *" {Write-Host "This is a Windows Server 2003 Machine" -ForegroundColor Green} +"* 2008 *" {Write-Host "This is a Windows Server 2008 Machine" -ForegroundColor Green} +"* 2012 *" {Write-Host "This is a Windows Server 2012 Machine" -ForegroundColor Green} +Default {Write-Host "This is the default" -ForegroundColor Green} +} +Write-Host "" + +# If Location is not set, ask user to input location +if ($Location -eq ""){ +$Location = Read-Host "Where is the sysprep file located? (ex. c:\temp) " +} + +# Cycle through Sysprep Folders on local machine +foreach($folder in $folders){ +if ($OS -eq "VCSA"){$Destination = "/etc/vmware-vpx/sysprep/$folder"} else {$Destination = "$vC_Partition\ProgramData\VMware\VMware VirtualCenter\Sysprep\$folder"} + +# Get files from each folder +Get-ChildItem "$($Location)\$($folder)" -ErrorAction SilentlyContinue | ForEach-Object { +$source = "$($Location)\$($folder)\$_" + +Write-Host "Transferring File `"$_`" " -ForegroundColor Green #Source = $source" -ForegroundColor Green +Write-Host "Destination = $Destination" -ForegroundColor Green + +# Copy Files to vCenter Sysprep folders +Copy-vmguestfile -source "$source" -Destination "$Destination" -VM "$target_vcenter" -LocalToGuest -GuestUser "$target_vcenter_user" -GuestPassword "$target_vcenter_password" + +} +} +Disconnect-viServer -confirm:$false diff --git a/Scripts/Sysprep_Automation_Script_v1a.ps1 b/Scripts/Sysprep_Automation_Script_v1a.ps1 deleted file mode 100644 index 64a5c9235096dc8676ec2c79612dc01c8c9c29e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8282 zcmchcYfoE85Qg`2rT&Lg2Pq+{Lr9~vO|OJok;0{zB>jLyxfnuYY}ba6H0@t+`#w8o zynAenA%e&#Fv=5K43M?czsTZ^&=S_s2rB(0gCl9t-tT{dz5w8Ql}gc&3O?o6(aNt@ypr@8cM| zXPQl1u;yH=J7pZ4NnT68cH^uQ#Y-zj3ZwY5Kji7d($mPX9Y$k=ecs019+bOa1=6a! z?ZxOs3i=bfh1OLgjb|zT*R}8HeY2w2SOY z`(UB#ZRpu9W_K=`RcJ+?wWGGKiRo%+Aqz_kTUIoKA#~d@i~PxPyQx_HHM|Hbfp4pN zuL-ZlHRIPXvWftn=2u6OSbeLpUiA8j5TL5ycPbtgaWDE4#E5P4xO)ztHp`e=8N|U< zSkUO9)>`zwlm!iqcogEDc8qVLW=i|9*O6wNh8^v^uWw%4*vTwNkz)CWHdJ8CB%+VH zN>uO1F`|OsmSaQ$zGhXSu`}&Jt+i_HaYRIb1(B9?8qETWKFcZc_gM3(3uFv79q9XE zS#ix4+hI7HE=J$8)Yj1D3hCaF&S-`Qyz^ic-H4r=;mg51(~0~n;uEVtt{Fbtm&P5* zdtai9{`4e^kA1B?lNHVAQ;(HHt?-<8KS&^nd{9_v-B ztNz-Iv6X67-X~Jtpi|yIQoRF97*0>oYktKi&PLo9d3=&H)hcZng1=uy83*#5)oHjy z5j_vDn2$ZtaPyp`8ajTyTeW)bOLJm}C?|jD2UQI22VQGpXj`gU_UkIO{zwu**(yX4 zQJ^vr_h8_)fP4dCDwM}4-F3JJ6k20Us4bhUI$)DUI?;iT>9y2`W_YLBeaY>YQHFiV zlfx)ue>Ioz?@H9u^40RNuN~3E>~KsC^=cGYC+kEEdh!_d5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