44 lines
1.0 KiB
PowerShell
Executable File
44 lines
1.0 KiB
PowerShell
Executable File
# Config laden
|
|
|
|
. "C:\\Shutdown\\Config.ps1"
|
|
|
|
# Module laden
|
|
|
|
Import-Module ".\\Modules\\Logging.psm1"
|
|
Import-Module ".\\Modules\\Credentials.psm1"
|
|
Import-Module ".\\Modules\\VCenter.psm1"
|
|
Import-Module ".\\Modules\\Shutdown.psm1"
|
|
|
|
# Logging
|
|
|
|
$LogFile = New-LogFile $Config.LogPath
|
|
Start-Transcript -Path $LogFile -Append
|
|
|
|
Write-Host "[INFO] Shutdown gestartet"
|
|
|
|
# Credentials
|
|
|
|
$vCenterCred = Get-CredentialFromFile $Config.CredFiles.vCenter
|
|
$storageCred = Get-CredentialFromFile $[Config.CredFiles.storage](http://Config.CredFiles.storage)
|
|
|
|
# vCenter Verbindung
|
|
|
|
Connect-ToVCenter -Server $Config.VCenterServer -Credential $vCenterCred
|
|
|
|
# CSV laden
|
|
|
|
$VMGroups = Import-Csv $Config.CSVGroups -Delimiter ";"
|
|
$VMGroups | ForEach-Object { $*.Gruppe = [int]$*.Gruppe }
|
|
$VMGroups = $VMGroups | Sort-Object Gruppe
|
|
|
|
# Shutdown Pipeline
|
|
|
|
Stop-UnknownVMs -VMGroups $VMGroups -ExcludeRegex "vCLS|vSAN"
|
|
|
|
Stop-VMsByGroup -VMGroups $VMGroups
|
|
|
|
Stop-VMHostSafe -VMHost "GWHost01"
|
|
|
|
Stop-ClusterSafe -Cluster $Config.Cluster -Reason "Automated Shutdown"
|
|
|
|
Stop-Transcript |