Initialer Import der Synology Scripts
This commit is contained in:
Executable
+63
@@ -0,0 +1,63 @@
|
||||
function Stop-VMsByGroup {
|
||||
param($VMGroups)
|
||||
|
||||
```
|
||||
$groups = $VMGroups.Gruppe | Select-Object -Unique
|
||||
|
||||
foreach ($g in $groups) {
|
||||
|
||||
$names = ($VMGroups | Where-Object Gruppe -eq $g).Server
|
||||
|
||||
$vms = Get-VM | Where-Object { $names -contains $_.Name }
|
||||
|
||||
foreach ($vm in $vms) {
|
||||
if ($vm.PowerState -eq "PoweredOn") {
|
||||
Shutdown-VMGuest -VM $vm -Confirm:$false -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
Start-Sleep -Seconds 60
|
||||
}
|
||||
```
|
||||
|
||||
}
|
||||
|
||||
function Stop-UnknownVMs {
|
||||
param($VMGroups, $ExcludeRegex)
|
||||
|
||||
```
|
||||
$vms = Get-VM | Where-Object {
|
||||
($VMGroups.Server -notcontains $_.Name) -and
|
||||
($_.Name -notmatch $ExcludeRegex)
|
||||
}
|
||||
|
||||
foreach ($vm in $vms) {
|
||||
if ($vm.PowerState -eq "PoweredOn") {
|
||||
Shutdown-VMGuest -VM $vm -Confirm:$false -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
}
|
||||
|
||||
function Stop-ClusterSafe {
|
||||
param(
|
||||
[string]$Cluster,
|
||||
[string]$Reason
|
||||
)
|
||||
|
||||
```
|
||||
Stop-VsanCluster -Cluster $Cluster -PowerOffReason $Reason -ErrorAction Stop | Out-Null
|
||||
```
|
||||
|
||||
}
|
||||
|
||||
function Stop-VMHostSafe {
|
||||
param([string]$VMHost)
|
||||
|
||||
```
|
||||
Set-VMHost -VMHost $VMHost -State Maintenance -Confirm:$false | Out-Null
|
||||
Stop-VMHost -VMHost $VMHost -Confirm:$false -ErrorAction Stop | Out-Null
|
||||
```
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user