39 lines
1009 B
PowerShell
39 lines
1009 B
PowerShell
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory)]
|
|
[string]$VMName,
|
|
[Parameter(Mandatory)]
|
|
[string]$VSphereFQDN,
|
|
[Parameter(Mandatory)]
|
|
[string]$VSphereUsername,
|
|
[Parameter(Mandatory)]
|
|
[string]$VSpherePassword
|
|
)
|
|
|
|
$PowerCliConfigurationSplat = @{
|
|
Scope = 'User'
|
|
ParticipateInCEIP = $False
|
|
Confirm = $False
|
|
InvalidCertificateAction = 'Ignore'
|
|
}
|
|
Set-PowerCLIConfiguration @PowerCliConfigurationSplat | Out-Null
|
|
|
|
$ConnectVIServerSplat = @{
|
|
Server = $VSphereFQDN
|
|
User = "$VSphereUsername"
|
|
Password = "$VSpherePassword"
|
|
WarningAction = 'SilentlyContinue'
|
|
}
|
|
Connect-VIServer @ConnectVIServerSplat | Out-Null
|
|
|
|
$RemoveVMSplat = @{
|
|
VM = "$($VMName)*"
|
|
DeletePermanently = $True
|
|
Confirm = $False
|
|
ErrorAction = 'SilentlyContinue'
|
|
}
|
|
Remove-VM @RemoveVMSplat
|
|
|
|
# Also delete ISO/floppy?
|
|
|
|
Disconnect-VIServer * -Confirm:$False |