The reaason you're having this problem with script 1 is because $global:vInventory doesn't contain a XML document but a string.
And the method SelectNodes is not known on a string.
Attached a corrected version of script 1.
The basic problem was this line
$global:vInventory = "<Inventory><Roles></Roles><Permissions></Permissions></Inventory>"
which should in fact be
$global:vInventory = [xml]"<Inventory><Roles></Roles><Permissions></Permissions></Inventory>"
Note how the string is 'cast' to an XML document !
Blog: LucD notes
Twitter: lucd22Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Thank you for the explanation and the corrected file.
Tested and fully working.
Do these scripts replace all roles or do they just add roles? Should they work the same on vCenter 4.1?
I see the script pulls the present roles but I can't see if they are retained or replaced ...
The script only exports the roles.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
I have downloaded the new scripts from virtu-al and the ones in this thread.
I am stuck with this error regardless of which import script I attempt. It creates 95% of the roles with no issue, but leaves one out. I have re-exported and reviewed the xml with no errors found.
I am presently attempting to verify "$privIds" via SDK.
[vSphere PowerCLI] Q:\psscripts> ./import-xml-roles-permissions.ps1
Exception calling "AddAuthorizationRole" with "2" argument(s): "A specified parameter was not correct.
At Q:\psscripts\import-xml-roles-permissions.ps1:7 char:48
+ $roleId = $authMgr.AddAuthorizationRole <<<< ($name,$privIds)
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
[vSphere PowerCLI] Q:\private drop\datadigitalglobe\psscripts>