PowerCLI הינו כלי המאפשר הרצה של סקריפטים בסביבת VMware. להלן מספר פעולות וקטעי קוד רלוונטיים העשויים להיות שימושיים:
הגדרת משתנים
הגדרת משתנים
$MyHosts = "192.168.0.101", "192.168.0.102" $username = "root" $password = "p@$$w0rd" $DomainSRV = "DOMAIN01", "DOMAIN02" $VirtualVC = "vCenter01"
שינוי הגדרות ה PowerCLI עבור חיבור בו זמנית למספר שרתי Host
$AllowMultiple = Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false
התחברות לשרתי ה Host וביצוע פעולות
$MyHosts | Foreach {
Write-Host "Connecting to host: $($_)"
$connection = Connect-VIServer $_ -User $username -Password $password
}
קבלת רשימת ה VM-ים שרצה בשרת Host$VM = Get-VM $DomainSRV
ריצה על כל ה VM שהתקבלו
$VM | Foreach {
Write-Host "VM $($_.name) found on $($_.VMHost)"
}
בדיקה ש VM תקין באמצעות סטטוס ה VM Tools המותקנים עליו$VM | Foreach {
do {
$VM = Get-VM $_
$Toolsstatus = $VM.ExtensionData.Guest.ToolsRunningStatus
Write-Host "VM tools status is $Toolsstatus"
}
}
אין תגובות:
הוסף רשומת תגובה