How to Add Hosts and Library Servers: Command-Line Examples

The examples in this topic show you how to use the Windows PowerShell - Virtual Machine Manager command shell to perform the following tasks:

  • Add a host server. A host server is a server on which the Virtual Machine Manager agent is installed and that you use as a host for virtual machines.
  • Add a library server. A library server is a server on which the Virtual Machine Manager agent is installed and that you use to store library resources, such as virtual machine templates, virtual hard disks, virtual floppy disks, ISO images, scripts, hardware profiles, and guest operating system profiles, as well as stored virtual machines.

Host and library servers are different from the Virtual Machine Manager server, on which the Virtual Machine Manager service is installed. By default, the Virtual Machine Manager server is also a library server. The Virtual Machine Manager server is not, by default, a virtual machine host but it can, optionally, act as a host.

Note

The Virtual Machine Manager server service requires a database to manage your Virtual Machine Manager environment. The Virtual Machine Manager database is stored either in Microsoft SQL Server 2005 on the Virtual Machine Manager server itself or on a separate server running Microsoft SQL Server 2005.

In addition to the examples provided here, other examples for how to add a host or a library server to Virtual Machine Manager are available in the command-line help.

How to Add a Virtual Machine Host

To add a server to Virtual Machine Manager that acts as a host on which to deploy virtual machines, type the following series of commands at the Virtual Machine Manager command prompt:

PS C:\> $Credential = Get-Credential
PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com"
PS C:\> Add-VMHost "VMHost01.Contoso.com" -Description "This is my new host" -VMRCEnabled $TRUE -VMRCPort 5900 -Credential $Credential

Explanation of each command line:

  • The first command uses Get-Credential to prompt you to supply a user name and password and stores your credentials in variable $Credential. The required credentials for this operation are either a local Administrator account or a domain account with administrator rights on the computer that you want to add as a host.
  • The second command connects to VMMServer1 in the Contoso.com domain and retrieves the server object from the Virtual Machine Manager database. The following command uses this server by default.
  • The third command adds the host object that represents VMHost01 in the Contoso domain to the Virtual Machine Manager database, specifies that Virtual Machine Remote Control (VMRC) is enabled, and specifies that TCP port 5900 will be used to connect to the VMRC service on VMHost01. As the last command is processed, variable $Credential provides your credentials to Add-VMHost.

For more information about how Windows PowerShell handles credentials, type at the command prompt:

Get-Help Get-Credential -detailed

For more information about how to use the command shell to add a host to Virtual Machine Manager, type at the command prompt:

Get-Help Add-VMHost

How to Add a Library Server

You can add a library server that stores Virtual Machine Manager resources by typing the following command at the Virtual Machine Manager command prompt:

PS C:\> Add-LibraryServer -VMMServer "VMMServer1.Contoso.com" -ComputerName "FileServer01.Contoso.com" -Description “Library server for lab”

Explanation of the command line:

  • This command adds a library server object that represents FileServer01 to the Virtual Machine Manager library catalog on VMMServer1, and describes FileServer01 as "Library server for lab." Both servers are in the Contoso.com domain.

For more information about how to use the command shell to add a library server to Virtual Machine Manager, type at the command prompt:

Get-Help Add-LibraryServer

See Also

Concepts

How to Create Library Resources: Command-Line Examples
How to Deploy or Store a Virtual Machine and Find a Suitable Host: Command-Line Examples
How to Enable Self-Service Users: Command-Line Examples