Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculates the parameters and then removes a Lability environment
param
(
[parameter(Mandatory = $true, HelpMessage = "Lability environment name")]
$environmentName ,
[parameter(Mandatory = $true, HelpMessage = "An idenfication leter)]
$prefix,
[parameter(Mandatory = $true, HelpMessage = "Used as an index for the prefix and to calculate the IP address ")]
$index,
)
if(!(Get-module Lability )) {
Import-Module Lability
}
write-host "Set the VM details Prefix $prefix$index"
$subnet = "192.168.$(255-$index).0/24"
# our wrapper for the lability command
if (Get-VmcLab | where { $_.Prefix -eq "$prefix$index"}) {
write-host "Removing VM $environmentName with Prefix $prefix$index "
# our wrapper for the lability command. Executes the Remove-LabConfiguration command, passing in the psd1 data file for the environment.
remove-vmclab -Environment $environmentName -prefix $prefix$index -Subnet $subnet -Confirm:$false
} else {
write-host "No VM $environmentName with Prefix $prefix$index to remove"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.