- Mastering PowerCLI
- Sajal Debnath
- 435字
- 2021-07-09 21:47:52
Using host profiles
In the preceding section, we learned how to manipulate and create custom ESXi images using PowerCLI cmdlets. So, now let's take a closer look at how to manipulate host profiles so that we can use both at a later stage in order to automate ESXi deployments. In case of VMware technologies, a host profile is a profile that stores all the configuration information of a host. We can configure an ESXi host as required and mark the host as the golden standard. Next, we create a host profile from the configuration of this host. Once the profile is ready, we can simply apply the profile to other hosts so that they can be automatically configured. This way, we can ensure consistency between host configurations across the entire infrastructure.
For this lab, we will get the following architecture:

We have a vcenter.lab.com server as a vCenter server. Under this, we have a datacenter named Datacenter. A cluster named Lab Cluster is created under Datacenter. The cluster has two ESXi hosts: esxi1.lab.com and esxi2.lab.com. We have chosen esxi1.lab.com as the golden host and will apply the host profile to the other host.
First, let's get a list of the commands available to manage a host profile.

So, first create a host profile from the command line using a standard host:
PS C:\Users\vcadmin> New-VMHostProfile -Name TestHostProfile -Description "Test Profile for Auto Deploy" -ReferenceHost esxi1.lab.com

We can check the status of the host profiles with the Get-VMHostProfile
cmdlet.
Since we have created a host profile, we now need to apply the profile to a host or cluster so that we can run further tasks on the profile.
We can apply a host profile to a host or cluster. In this example, we will apply this on a cluster and keep the level as –AssociateOnly
. As the name suggests, it will only associate the host profile with the host and will do nothing else.

Now, we can check the compliance of a host in this cluster with the host profile that we attached to it.

Clearly, the host is not compliant with the profile. So, let's apply the profile now. We can apply the profile with the same Invoke-VMHostProfile
cmdlet but without the –AssociateOnly
switch; however, before we go ahead and apply the profile, we need to put the host into maintenance mode. While we apply the policy, we can see that certain values need to be provided first (for example, vMotion IP and so on).

We can supply the required values to a variable and then apply the variable to get the end result.
- Java Web開發學習手冊
- 大學計算機應用基礎實踐教程
- Android開發精要
- 零基礎學Scratch少兒編程:小學課本中的Scratch創意編程
- 技術領導力:程序員如何才能帶團隊
- Java Web應用開發技術與案例教程(第2版)
- 大數據分析與應用實戰:統計機器學習之數據導向編程
- HTML5與CSS3基礎教程(第8版)
- Learning Apache Karaf
- Learning Apache Cassandra
- 從零開始學Android開發
- 并行編程方法與優化實踐
- Machine Learning for OpenCV
- Visual C++程序設計與項目實踐
- Microsoft Exchange Server 2016 PowerShell Cookbook(Fourth Edition)