Export-HostProfile
VMware: Exports the specified host profile to a file
#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]$Name,
[Parameter(Mandatory = $true)]
[string]$FilePath
)
Process {
$vmServer = $null
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$hProfile = Get-VMHostProfile -Name $Name -Server $vmServer -ErrorAction Stop
Export-VMHostProfile -FilePath $FilePath -Profile $hProfile -Force:$true -Server $vmServer -ErrorAction Stop
$output = [PSCustomObject]@{
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Status = "Success"
Message = "Host profile $Name successfully exported to $FilePath"
}
Write-Output $output
}
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 of the host profile to export
Path to the file where to export the host profile