This script exports and imports patch baselines from one Update Manager server to another.
Before running the script, make sure that you have vSphere PowerCLI 4.0 U1 and vCenter Update Manager PowerCLI 4.0 U1 installed on your machine. If you have vCenter Update Manager PowerCLI 4.1 installed use ExportImportBaselines_41.ps1. If you have vSphere Update Manager PowerCLI 5.0 installed use ExportImportBaselines_50.ps1.
To use the script
1. Run the Get-PatchBaseline cmdlet to retrieve the patch baselines you want to import.
2. Supply the retrieved baselines and one or more destination vCenter Server(s) for the script parameters and run the script.
On each destination server, the script creates duplicates of the provided baselines.
Feedback welcome!
Nice Script, great job.
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
This isn't working for me. I found PowerCLI while looking for a VUM export/import script. It's new to me. My vCenter servers are new builds of WS2K8x64 and vCenter 4.1. I have powershell installed and the 4.1 versions of PowerCLI and Update Manager PowerCLI.
The error I get is "Unable to find type : make sure that the a ssembly containing this type is loaded. At D:\PowerCLI\SCripts\ExportImportBaselines_40U1.ps1:28 char:118
+ function ExtractPatchesFromServer([VMware.VumAutomation.Types.Patch[]]$patches,VMware.VimAutomation.Types.VIServer]$ <<<< destinationServer){"
Any suggestions?
This script was written for PowerCLI 4.0u1. Unfortunately the types in PowerCLI 4.1 have changed.
The 'VMware.VimAutomation.Types.VIServer' type has become 'VMware.VimAutomation.ViCore.Impl.V1.VIServerImpl.
If you replace the type, the script should work.'
____________
Blog: LucD notes
Twitter: lucd22
Thanks for the response. I tried your suggestion. No joy.
It looks like the types for Update Manager Power CLI have also changed in 4.1. Now I get, "Unable to find type [VMware.VumAutomation.Types.Patch[]]: make sure that the assembly containing this type is loaded. At D:\PowerCLI\Scripts\ExportImportBaselines_40U1.ps1:28 char:71
+ function ExtractPatchesFromServer([VMware.VumAutomation.Types.Patch[]]$ <<<<
patches, $destinationServer){"
I'm not sure where to find a cross reference to get the new object type.
This type is not changed. Could you check that the Update Manager Power CLI snap-in is added to the current console? Please, run Get-PSSnapin. The VMware.VumAutomation snap-in should be listed.
If it is not there, run Add-PSSnapin "VMware.VumAutomation" and try to execute the script again.
You were correct. I reinstalled UpdateManager PowerCLI to resolve the missing snapin problem. I think I created that problem troubleshooting the other error.
Unfortunately, I still can't get the script to work. I'm a little confused by the usage comments at the begining. It looks like the intention was pass the source, destination and baseline name as command line parameters, but the example only includes 2 of the three.
I tried uncommenting the declarations for $destinationServer, $sourceServer, and $baselines, and plugging in the appropriate addresses and baseline name.
Now when I run the script I get this error:
The term 'param' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At D:\PowerCLI\Scripts\ExportImportBaselines_40U1_mod.ps1:22 char:6 + Param( <<<< [VMware.VumAutomation.Types.Baseline[]] $baselines, [VMware.VimAutomation.ViCore.Impl.V1.VIServerImpl[]]$destinationServers)
The script doesn’t have parameter for source server, because baseline contains info for the sever it comes from.
You receive this error because the declarations of $destinationServer, $sourceServer and $baselines are before the beginning of the script. They should be after the line: Param([……
Note that this way, you should change a little the example. You should use $destinationServers instead of $destinationServer:
$destinationServers = Connect-VIServer
$baselines = Get-PatchBaseline MyBaseline -Server $sourceServer
We could certainly use this script. However, when I run it, I get the following errors:
Unable to find type : make sure that the assembly containing this type is loaded.
At D:\dgtmp\ExportImportBaselines_svvs.ps1:50 char:70
+ CategoryInfo : InvalidOperation: (VMware.VumAutom...pdateTargetType:String) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
Write-Warning : A positional parameter cannot be found that accepts argument 'Patch'.
At D:\dgtmp\ExportImportBaselines_svvs.ps1:69 char:16
+ Write-Warning <<<< -Message "Unknown baseline type '" $baseline.BaselineType "'"
+ CategoryInfo : InvalidArgument: ( , ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteWarningCommand
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-PSSnapin "VMware.VumAutomation" | fl -Property Version
Version : 4.1.0.5395
I use the script like so:
$destinationServers = Connect-VIServer
$baselines = Get-Baseline "My Baseline" -Server $sourceServer
c:\ps\ExportImportBaselines_VUMU2.ps1 $baselines $destinationServers
Are you sure that you are using the original script? There is no such variable
$targetType = ....
Great script, will make the migration of our Update Manager so much easier.
Does this script copy or move?
And does it take a long time to run?
Fails with error:
update:
At best I can get to run but it just goes into a logon promt loop.
update 2
Well after I moved the Param line to the top and removed the
c:\ps\ExportImportBaselines_VUMU2.ps1 $baselines $destinationServers line I was able to get it to work.