Hi Luc;
As mentioned above, the script you suggested as well as a few others I've been able to locate within this Forum all fail in one or another. Am truly hoping you can help with this one...
I have 2 scripts which I've attached for your review. One script exports/imports vCenter Roles/Permissions while the other exports and imports folders and
corresponding permissions. Since we will be performing fresh vSphere 5.1 installs, we do not need to migrate hosts or even VMs at this time. Manual migration of VMs will take place after successful creation of VM folders/permissions.
I'm getting inconsistent and improper results mainly with Permissions when using both. This has been validated after I perform a manual check afterwards. There are also many looping errors of which I've tabled below for your info. Most of these errors were reported by other users. Unfortunately no one has yet resolved these issues.
The results of both scripts are litsed below.
1) Migrate vCenter Folders and Permissions Script
Summary: As far as importing folders are concerned, this part seems to work but getting many Folder "not found" errors; the source of whick look to be "default"
vCenter 4.1 folder hierarchy...i.e. 'Hosts & Clusters'. The following is an example of the many repetitive output errors following execution:
Get-View : Cannot validate argument on parameter 'Id'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\migrate-vcenter-newest-test.ps1:84 char:44
+ $Foldername = (Get-View -id <<<< $perm.EntityId).Name
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Exception calling "SetEntityPermissions" with "2" argument(s): "The object has already been deleted or has not been completely created"
At C:\migrate vcenter folders and permissions.ps1:170 char:35
+ $doactual.SetEntityPermissions <<<< ($entity, $setperm)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Get-Folder : 18/02/2013 5:06:49 PM Get-Folder Folder with name 'Hosts & Clusters' was not found using the specified filter(s).
At C:\migrate vcenter folders and permissions.ps1:148 char:71
+ $entity.value = ((get-datacenter $datacenter | get-folder <<<< $perm.Foldername).ID).Trimstart("Folder-")
+ CategoryInfo : ObjectNotFound: (:) [Get-Folder], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetFolder
You cannot call a method on a null-valued expression.
At C:\migrate vcenter folders and permissions.ps1:148 char:103
+ $entity.value = ((get-datacenter $datacenter | get-folder $perm.Foldername).ID).Trimstart <<<< ("Folder-")
+ CategoryInfo : InvalidOperation: (Trimstart:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
2) Export-Import vCenter Roles Script
Summary: The following is an example of the many repetitive output errors following execution:
Exception calling "SetEntityPermissions" with "2" argument(s): "
Required parameter entity is missing
while parsing call information for method SetEntityPermissions
at line 1, column 218
while parsing SOAP body
at line 1, column 207
while parsing SOAP envelope
at line 1, column 38
while parsing HTTP request for method setEntityPermissions
on object of type vim.AuthorizationManager
at line 1, column 0"
At C:\Export_Import Roles Newest.ps1:97 char:43
+ $perms = $authMgr.SetEntityPermissions <<<< ($object.MoRef,@($permission))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
A few other error messages such as.....
Exception calling "AddAuthorizationRole" with "2" argument(s): "A specified parameter was not correct.
privIds"
At C:\Export_Import Roles Newest.ps1:81 char:44
+ $roleId = $authMgr.AddAuthorizationRole <<<< ($name,$privIds)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Get-View : 18/02/2013 3:08:09 PM Get-View The request failed with HTTP status 501: Not Implemented.
At C:\Export-Import vCenter Roles .ps1:171 char:19
+ $entity = Get-View <<<< -ViewType $_.EntityType -Filter @{"Name"=$EntityName}
+ CategoryInfo : NotSpecified: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Set-Permission : Cannot process argument transformation on parameter 'object'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type
"VMware.Vim.ManagedEntity".
At C:\Export-Import vCenter Roles .ps1:172 char:15
+ Set-Permission <<<< $entity $perm
+ CategoryInfo : InvalidData: (:) [Set-Permission], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Permission
I'm not a scripting guy so I'm not sure where the problems lies. Either the scripts cannot be run in (any) sequence or they contain cmdlets/attributes which are not
compatible with vCenter 5.1 (or maybe both).
Any assistance you can provide would be appreciated. Thx
Ron