Skip to content

Instantly share code, notes, and snippets.

Write-Host "Disconnecting The ISO From "$VM.Parent.Name""
Get-CDDrive -VM $VM.Parent.Name | Set-CDDrive -NoMedia -Confirm:$false > $null
Get-VM | Get-CDDrive | where {$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Confirm:$False
Function Deploy-VM {
Param (
[parameter (Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$VMNames
)
}
Function Deploy-VM {
[CmdletBinding()]
Param (
[parameter (Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$VMNames
)
Function Deploy-VM {
[CmdletBinding()]
Param (
[parameter (Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$VMNames
)
Function Deploy-VM {
[CmdletBinding()]
Param (
[parameter (Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$VMNames
)
#############################################################
# Define variables to "Create all VMs specified in $NewVms" #
#############################################################
Write-Host "Enter The FQDN Of The ESXi Server That Will Host The Guest VM: " -ForegroundColor Yellow -NoNewline
$ESXiHost = Read-Host
#Needed To Create An Array From The Comma Separated List Stored In "$NewVMs"
Write-Host "Enter The Name Of The New Guest VM " -ForegroundColor Yellow -NoNewline
Write-Host "(Enter Multiples As A Comma Separated List)" -ForegroundColor Green -NoNewline
###############################
# Load VMware PowerCLI Module #
###############################
. 'C:\Program Files\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1'
cls
###########################################
# Define variables to "Connect To Server" #
###########################################
###########################
# 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
##########################
# 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 ""