Public/Stop-OftenOnLab.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function Stop-OftenOnLab {
    [CmdletBinding()]
    param (
        [switch] $TurnOff
    )

    $configurationData = Get-OftenOnLabConfiguration
    if (!$TurnOff) {
        Stop-Lab -ConfigurationData $configurationData -ErrorAction:Continue
    } else {
        $configurationData.AllNodes.NodeName -ne "*" | ForEach-Object {
            Stop-VM -Name $_ -TurnOff -ErrorAction:SilentlyContinue
        }
    }
}