New-HostProfile
VMware: Creates a new host profile based on a reference host
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[Parameter(Mandatory = $true)]
[string]$ProfileName,
[Parameter(Mandatory = $true)]
[string]$HostName,
[switch]$CompatibilityMode,
[string]$Description
)
Process {
$vmServer = $null
try {
if ([System.String]::IsNullOrWhiteSpace($Description)) { $Description = " " }
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$vmHost = Get-VMHost -Server $vmServer -Name $HostName -ErrorAction Stop
$null = New-VMHostProfile -Server $vmServer -Name $ProfileName -ReferenceHost $vmHost -CompatibilityMode:$CompatibilityMode -Description $Description -ErrorAction Stop
$result = Get-VMHostProfile -Server $vmServer -Name $ProfileName -ErrorAction Stop | Select-Object *
foreach ($item in $result) {
$item | Add-Member -NotePropertyName 'Timestamp' -NotePropertyValue $timestamp -Force
Write-Output $item
}
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Name for the new host profile
Name of the reference host
Off
Make profile compatible with ESX/vCenter Server versions earlier than 5.0
Description for the new host profile