本文件已封存並已停止維護。

UpdateVMMAgents.ps1

更新日期: 2009年9月

適用於: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2, Virtual Machine Manager 2008 R2 SP1

After you upgrade your System Center Virtual Machine Manager (VMM) server to VMM 2008 or VMM 2008 R2, you must update the agents on your hosts and library servers. The following script uses the Get-VMMManagedComputer cmdlet to get all the hosts and library servers that are managed by the VMM server and that need to have their agent software updated. After requesting credentials for a user who has permissions to update the hosts and library servers, the script loops through the managed computers in the $VMMManagedComputers variable. The script uses the Update-VMMManagedComputer cmdlet to asynchronously update the agent software so that all the managed computers can be updated simultaneously. The script filters out types of hosts that you will need to manually update, such as perimeter network hosts.

note附註
If the hosts are in a Needs Attention state after you update the agents, an update may be available for the virtualization software that is used on that host. View the Status tab of the Properties page for the host to determine whether an update is available. To update Virtual Server hosts, right-click the host in the VMM Administrator Console, and then click Update Virtual Server. To update Hyper-V hosts, go to Windows Update to check for the latest updates for Hyper-V and Background Intelligent Transfer Service (BITS).

For more information about how to upgrade your VMM environment, see Upgrading VMM (http://go.microsoft.com/fwlink/?LinkID=159862).

Disclaimer


# Filename:      UpdateVMMAgents.ps1
# Description:   Updates the Virtual Machine Manager (VMM) agent on
#                any host or library server that is managed by VMM 
#                and is running an earlier version of the agent software.

# Connect to the VMM server.

Get-VMMServer -ComputerName "VMMServer01.Contoso.com" | out-null

# When prompted, type the user name and password of an account
# with permissions to update both hosts and library servers.

$Creds = Get-Credential

# Get each managed computer that is not running
# the current version of the VMM agent software.

$VMMManagedComputers = Get-VMMManagedComputer | where {$_.VersionState -ne "UpToDate"}

# Filter out non-supported hosts, and then loop through each host
# and library server and update its VMM agent software.

Foreach ($vmmmanagedcomputer in $vmmmanagedcomputers) 
{
   If ($VMMManagedcomputer.Role -contains "Host")
   {
      $VMHost = get-vmhost -computername $VMMManagedcomputer.Name

      If (($VMHost.PerimeterNetworkHost -ne "True") -AND ($VMHost.NonTrustedDomainHost -ne "True") -AND ($VMHost.VirtualizationPlatform -ne "VMWareESX"))
      {
         Update-VMMManagedComputer -VMMManagedComputer $VMMManagedcomputer -Credential $Creds -RunAsynchronously | out-null
         Write-Host "Updating agent on host $VMHost"
         Write-Host ""
         Write-Host "####################################################"
      }

   }
   ElseIf ($VMMManagedcomputer.Role -contains "Library")
   {
      Update-VMMManagedComputer -VMMManagedComputer $VMMManagedcomputer -Credential $Creds -RunAsynchronously | out-null
      write-host "Updating agent on library server $VMMManagedcomputer"
      Write-Host ""
      Write-Host "####################################################"
   }
}
顯示: