Good Day,
I am trying to create a script that will import a Customization Specification (Custom Spec) that was created in a different vCenter. As we know the Password for the local administrator gets encrypted by the vCenter where the Custom Spec was created so when you import this Custom Spec into a new vCenter it tells you that the public key in the specification does not match the vCenter public Key. The it tells you to click OK to reenter the password to continue the re-import. So with this in mind I am trying to accomplish this task using Powershell ISE script. I Add the PSSnapin for VMware so I can run the VMware cmdlets so that is not a problem. Here is the Code I am using:
################################
#Imports Customization Profiles #
################################
cd 'F:' (This is where the .XML file resides for the Custom Spec to import.)
$Path = "."
$view = Get-View CustomizationSpecManager
Write-host $View
ForEach ($xmlfile in (Get-ChildItem -Path $path | where {$_.extension -eq ".xml"})) {
$xml = Get-Content ($xmlfile)
#Imports all XML Files into the current vCenter
$view.CreateCustomizationSpec($view.XmlToCustomizationSpecItem($xml))
$adminPwd = read-host -prompt "Input new local admin pwd"
$Myspec = Get-OSCustomizationSpec -Name "My Imported Custom Spec"
Write-Host "AdminPW is" $adminPwd (This was added to test if the data entered was being passed correctly)
Write-Host "Current Specification is" $Myspec (This was added to test if the data entered was being passed correctly)
set-OScustomizationSpec -OSCustomizationSpec $MySpec -adminPassword $adminPwd
}
The Custom Spec is imported correctly but when I try and change the password I get the following error.
Set-OSCustomizationSpec : This cmdlet requires 32bit process. Please run PowerCLI in 32 bit mode.
At E:\scripts\Create_Folders-Import_Templates-Deploy_Templates.ps1:79 char:24
+ set-OScustomizationSpec <<<< -OSCustomizationSpec $MySpec -adminPassword $adminPwd
+ CategoryInfo : NotSpecified: (:) [Set-OSCustomizationSpec], ViError
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.SetCustomizationSpec
So viewing the help details of the Set-OSCustomizationSpec reveils that you indeed have to run this command from the 32bit PowerCLI window. Is there a way to run this cmdlet from the 64 bit Powershell ISE window or is there a better way to accomplish this task?
Thanks,
Mitch