Last active
January 6, 2020 14:16
-
-
Save rfennell/d558549b853297db5a1ea904b39cc566 to your computer and use it in GitHub Desktop.
Calculates the parameters and then removes a Lability environment
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
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