27 lines
808 B
Markdown
Executable File
27 lines
808 B
Markdown
Executable File
. "C:\\Shutdown\\Config.ps1"
|
|
|
|
Import-Module ".\\Modules\\Logging.psm1"
|
|
Import-Module ".\\Modules\\Retry.psm1"
|
|
Import-Module ".\\Modules\\Credentials.psm1"
|
|
Import-Module ".\\Modules\\VCenter.psm1"
|
|
Import-Module ".\\Modules\\Shutdown.psm1"
|
|
|
|
Start-Transcript -Path (Join-Path $Config.LogPath "shutdown.log")
|
|
|
|
Write-Log "Shutdown started"
|
|
|
|
$vCenterCred = Get-CredentialFromFile $Config.CredFiles.vCenter
|
|
|
|
Connect-ToVCenter -Server $Config.VCenterServer -Credential $vCenterCred
|
|
|
|
$VMGroups = Import-Csv $Config.CSVGroups -Delimiter ";"
|
|
$VMGroups | ForEach-Object { $*.Gruppe = [int]$*.Gruppe }
|
|
|
|
Stop-UnknownVMs -VMGroups $VMGroups -ExcludeRegex "vCLS|vSAN"
|
|
Stop-VMsByGroup -VMGroups $VMGroups
|
|
|
|
Stop-ClusterSafe -Cluster $Config.Cluster -Reason "Automated shutdown"
|
|
|
|
Write-Log "Shutdown completed"
|
|
|
|
Stop-Transcript |