1.Get-VMHostProfile
功能:获取可用的主机配置文件。
语法:
Get-VMHostProfile [[-Name] <String[]>] [-Description <String[]>] [-Entity <InventoryItem[]>] [-ReferenceHost <VMHost[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-VMHostProfile -Name Profile
2.Set-VMHostProfile
功能:修改指定的主机配置文件。
语法:
Set-VMHostProfile [[-Name] <String>] [[-ReferenceHost] <VMHost>] [-Profile] <VMHostProfile> [-Description <String>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$profile = ( Get-VMHostProfile -Name Profile )[0] Set-VMHostProfile -Profile $profile -Description "New description."
3.New-VMHostProfile
功能:创建一个基于主机参考的新的主机配置文件。
语法:
New-VMHostProfile [-Name] <String> [-ReferenceHost] <VMHost> [-Description <String>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$h = Get-VMHost 10.23.134.133
New-VMHostProfile -Name testProfile -Description "This is my first test profile." -ReferenceHost $h
4.Apply-VMHostProfile
功能:应用主机配置文件到指定的主机或群集。
语法:
Apply-VMHostProfile [-Entity] <InventoryItem> [-Profile <VMHostProfile>] [-Variable <Hashtable>] [-AssociateOnly] [-ApplyOnly] [-RunAsync] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
$profile = Get-VMHostProfile -Name Profile Apply-VMHostProfile -Entity Host -Profile $profile -Confirm:$false
(2)
$profile = Get-VMHostProfile -Name Profile Apply-VMHostProfile -AssociateOnly -Entity Cluster -Profile $profile -Confirm:$false
(3)
$profile = Get-VMHostProfile -Name Profile Apply-VMHostProfile -AssociateOnly -Profile $profile -Entity (Get-Cluster)
(4)
$profile = Get-VMHostProfile -Name Profile $additionalConfiguration = Apply-VMHostProfile -ApplyOnly -Profile $profile -Entity 10.23.114.166 $additionalConfiguration['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-VMkernel"].ipConfig.IpAddressPolicy.address'] = '10.0.0.128' $additionalConfiguration['network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-VMkernel"].ipConfig.IpAddressPolicy.subnetmask = '255.255.255.0' Apply-VMHostProfile -ApplyOnly -Profile $profile -Entity 10.23.114.166 -Variable $additionalConfiguration
(5)
Apply-VMHostProfile -Profile $profile -Entity 10.23.114.166
5.Remove-VMHostProfile
功能:删除指定的主机配置文件。
语法:
Remove-VMHostProfile [-Profile] <VMHostProfile[]> [[-Server] <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-VMHostProfile -Entity <InventoryItem[]> [[-Server] <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Get-VMHostProfile -Name Profile | Remove-VMHostProfile -Confirm:$false
6.Import-VMHostProfile
功能:从一个文件中导入主机配置文件。文件路径必须从vSphere PowerCLI客户端访问。
语法:
Import-VMHostProfile [-FilePath] <String> [-Name] <String> [[-ReferenceHost] <VMHost>] [-Description <String>] [-Server <VIServer>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Import-VMHostProfile -FilePath export.prf -Name Profile
7.Export-VMHostProfile
功能:导出指定的主机配置文件到一个文件。
语法:
Export-VMHostProfile [-FilePath] <String> [-Profile] <VMHostProfile> [-Force] [-Server <VIServer>] [<CommonParameters>]
例子:
$profile = (Get-VMHostProfile -Name Profile )[0] Export-VMHostProfile -FilePath export.prf -Profile $profile –Force
8.Test-VMHostProfileCompliance
功能:测试主机配置文件的兼容性。
语法:
Test-VMHostProfileCompliance [-VMHost] <VMHost[]> [-UseCache] [[-Server] <VIServer[]>] [<CommonParameters>]
Test-VMHostProfileCompliance [-Profile] <VMHostProfile[]> [-UseCache] [[-Server] <VIServer[]>] [<CommonParameters>]
例子:
(1)
Test-VMHostProfileCompliance -VMHost Host
(2)
$profile = Get-VMHostProfile -Name Profile Apply-VMHostProfile -AssociateOnly -Profile $profile -Entity 10.0.0.126 Test-VMHostProfileCompliance -VMHost 10.0.0.126 | fl *
(3)
Test-VMHostProfileCompliance -Profile $profile | fl *