diff --git a/VMware.Snapshot-CDdrive.check b/VMware.Snapshot-CDdrive.check deleted file mode 100644 index 3be44ad..0000000 --- a/VMware.Snapshot-CDdrive.check +++ /dev/null @@ -1,56 +0,0 @@ -Import-Module VMware.VimAutomation.Core -Set-PowerCLIConfiguration -InvalidCertificateAction Prompt -Confirm:$false - -# Verbindung vCenter -Connect-VIServer -Server "SERVER" -User "administrator@vsphere.local" -Password "PASSWORD" - - -$clusterName = "CLUSTER" -$folderName = "FOLDER" - -# Get the cluster object -$cluster = Get-Cluster -Name $clusterName - -# Get the folder object recursively -$folder = Get-Folder -Name $folderName -Location (Get-Folder -NoRecursion | Where-Object { $_.Name -eq $folderName }) - -# Get all VMs in the specified folder and its subfolders that are on hosts in the specified cluster -$vms = Get-VM -Location $folder | Where-Object { $_.VMHost.Parent -eq $cluster } - -# Check jede VM und prüfe die CD/DVD-Laufwerke und Snapshots -foreach ($vm in $vms) { - $cdDrives = Get-CDDrive -VM $vm - $snapshots = Get-Snapshot -VM $vm -ErrorAction SilentlyContinue - - # Prüfe, ob ein verbundenes CD/DVD-Laufwerk vorhanden ist - $cdDriveConnected = $false - foreach ($cdDrive in $cdDrives) { - if ($cdDrive.ConnectionState.Connected) { - $cdDriveConnected = $true - break - } - } - - # Prüfe, ob Snapshots vorhanden sind - $snapshotExists = $false - if ($snapshots) { - $snapshotExists = $true - } - - # Füge das Ergebnis zur Liste hinzu - $results += [PSCustomObject]@{ - VMName = $vm.Name - CDDriveConnected = $cdDriveConnected - SnapshotExists = $snapshotExists - } -} - -# Generiere einen Dateinamen mit aktuellem Datum und Uhrzeit -$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" -$filepath = "C:\Users\DeineMuddaTV\Desktop\Output\Snapshot-and-CD-Check_$timestamp.csv" - -# Exportiere die Ergebnisse in eine CSV-Datei -$results | Export-Csv -Path $filepath -NoTypeInformation - -# Trenne die Verbindung zum vCenter-Server -Disconnect-VIServer -Confirm:$false \ No newline at end of file