This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-VM | Get-CDDrive | where {$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Confirm:$False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
# Get User Credentials To Pass To Guest OS # | |
############################################ | |
$Creds = Get-Credential | |
###################################################################### | |
# Get All CentOS Linux VMs With A Configured ISO Path # | |
# Use Invoke-VMScript To Eject The Mounted Media Inside The Guest OS # | |
# Disconnect The ISO From The VM # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Deploy-VM { | |
[CmdletBinding()] | |
Param ( | |
[parameter (Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
$VMNames | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Deploy-VM { | |
[CmdletBinding()] | |
Param ( | |
[parameter (Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
$VMNames | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Deploy-VM { | |
Param ( | |
[parameter (Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
$VMNames | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Deploy-VM { | |
[CmdletBinding()] | |
Param ( | |
[parameter (Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
$VMNames | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################### | |
# Load VMware PowerCLI Module # | |
############################### | |
. 'C:\Program Files\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1' | |
cls | |
########################################### | |
# Define variables to "Connect To Server" # | |
########################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################## | |
# Disconnect From Server # | |
########################## | |
Write-Host "" | |
Write-Host "Closing Connection To Server: " -ForegroundColor Green -NoNewline | |
Write-Host "$ServerInstance " -ForegroundColor Cyan | |
Disconnect-VIServer -Server $ServerInstance -Force -Confirm:$false | |
Write-Host "" | |
Write-Host "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### | |
# Display VM Build Status # | |
########################### | |
$RunningTasks = $TaskTable.Count | |
while($RunningTasks -gt 0){ | |
Get-Task | foreach { | |
if($TaskTable.ContainsKey($_.Id) -and $_.State -eq "Success"){ | |
Write-Host " VM " -ForegroundColor Green -NoNewline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################## | |
# Create Hash Table # | |
# Create All VMs In $NewVMs # | |
# Populate Hash Table with Id of Each VM Creation Task # | |
######################################################## | |
$TaskTable = @{} | |
foreach ($VM in $NewVMs){ | |
$TaskTable[(New-VM -Name $VM -Template $VMTemplate -VMHost $ESXiHost -Location $VMLocation -Datastore $VMDatastore -RunAsync).Id] = $VM |