Create / Import host profile from existing config – PS PowerCLI

Share This:

https://github.com/cann0nf0dder/PS_PowerCLI.git

<#
NAME: Import_Host_Profile.ps1
AUTHOR: Chris Danielewski
DATE : 8/22/2017
PURPOSE: This script will import host profile from config location

OUTPUT: N/A
REQUIRED UTILITIES: PowerCLI,

==========================================================================
CHANGE HISTORY:
GE HISTORY:
v1.0 8/23/2017 CD New script!
#>

param(
[Parameter(Mandatory=$true)][String]$location
)

#environemt
$profile_name = “Imported_profile”
$pathTOprofile = $location + “profile.vpf”

$obj = Get-View ServiceInstance
$hpobj = Get-View -Id $obj.Content.HostProfileManager

$spec = New-Object VMware.Vim.HostProfileSerializedHostProfileSpec
$spec.Name = $profile_name
$spec.Enabled = $true
$spec.Annotation = “Imported via automation”
$spec.Validating = $false
$spec.ProfileConfigString = (Get-Content -Path $pathTOprofile)

$hpobj.CreateProfile($spec)

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.