Initialer Import der Synology Scripts

This commit is contained in:
root
2026-08-05 08:43:57 +02:00
commit 5e32a7c411
404 changed files with 79932 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
function Get-CredentialFromFile {
param([string]$Path)
```
if (!(Test-Path $Path)) {
throw "Credential file not found: $Path"
}
return Import-Clixml -Path $Path
```
}
+25
View File
@@ -0,0 +1,25 @@
function New-LogFile {
param($LogPath)
```
if (!(Test-Path $LogPath)) {
New-Item -ItemType Directory -Path $LogPath | Out-Null
}
return Join-Path $LogPath ("Shutdown_{0}.log" -f (Get-Date -Format "yyyy-MM-dd_HH-mm-ss"))
```
}
function Write-Log {
param(
[string]$Message,
[string]$Level = "INFO"
)
```
$line = "[{0}] {1}" -f $Level, $Message
Write-Host $line
```
}
+63
View File
@@ -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
```
}
+15
View File
@@ -0,0 +1,15 @@
function Connect-ToVCenter {
param(
[string]$Server,
[pscredential]$Credential
)
```
Import-Module VMware.PowerCLI -ErrorAction Stop
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
Connect-VIServer -Server $Server -Credential $Credential -ErrorAction Stop | Out-Null
```
}