Automation

 View Only
Expand all | Collapse all

export and import permission between 2 vcenter

  • 1.  export and import permission between 2 vcenter

    Posted Apr 27, 2021 02:46 PM

    Hello,

    because a update killed our vcetner vmware suggested we build a new one.

    I have already importet the roles + permission to that role

    how can I Export and Import the permission of a of all roles on all objects e.g datacenters and folders.

    will be nice if there is an easy way.

    by tutti



  • 2.  RE: export and import permission between 2 vcenter



  • 3.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 03:16 PM

     powershell cant recognize export-excel

    seem like I cant do it with Excel Export is it possible to do it with Standard thinks where I dont Need to download Moduls



  • 4.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 03:48 PM

    Sure, you can use Export-Csv to two separate CSV files.



  • 5.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 04:01 PM

    ok now I have to files how do I Import this to the new vcenter?



  • 6.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 04:12 PM

    The import part is also in that thread



  • 7.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 04:33 PM

    but I have now 2 files and not 1 csv, can I just do 1 file and then run again with the other?

    I did run them and I get "new-VIPermission: System.String cant convert to System Boolean"

    is it because the csv dont have worksheet names?



  • 8.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 05:09 PM

    You can have 2 different types of objects in the same CSV.
    So it is either 2 CSV files or work with the Worksheets



  • 9.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 05:25 PM

    I get this

     

    New-VIPermission : "System.String" can not be converted to "System.Boolean", for the Parameter "Propagate" is needed.
    In Z:\Vmware\script\import vcenter.ps1:12 Zeichen:22
    +     New-Vipermission
    +                      ~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [New-VIPermission], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgument,VMware.VimAutomation.ViCore.Cmdlets.Commands.PermissionManagement.NewVIPermission
     



  • 10.  RE: export and import permission between 2 vcenter
    Best Answer

    Posted Apr 27, 2021 05:40 PM

    That depends what you have in the Propagate column in the CSV.

    You could try with

    Propagate = [Boolean]$row.Propagate


  • 11.  RE: export and import permission between 2 vcenter

    Posted Apr 27, 2021 05:51 PM

    Ok thanks that worked and because I already had the roles in there I only need 1 csv



  • 12.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 08:54 AM

    Hello Lucd it seems not all permissions where set I got some lines with

     

    New-VIPermission : the argumentiontransformation for the parameter "Entity" could not be processed. This parameter no longer accepts an array. As an
    alternative you may pass multiple values by pipeline (if supported by the parameter).



  • 13.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 09:06 AM

    That could mean that you have entities (VM, Folders...) with the same name in the target vCenter.



  • 14.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 09:10 AM

    yeah in the Import file I have 10 with the exact same lines with "UserXXX","admin","true","Test"","Folder"

    so the script doesn't knwo the exact location of the folders.Can you help me to change this or is that not possible?



  • 15.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 09:25 AM

    Yes, that is possible when you use the full path in the export.
    As I mentioned in Export / Import folder permissions - VMware Technology Network VMTN you can combine the export with the Get-FolderPath function.



  • 16.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 11:53 AM

    I only get VIobject is empty on the Folder script. I not really good with powershell can you help me merge the Folder and permission script to the Import and Export script?



  • 17.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 12:24 PM


  • 18.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 12:49 PM

    ok so I get a error that I have multible Datacenter in the vcenter  but I only named  one under "datacenter"

     

    then in the import script it tells me something with switches what I dont know what to do



  • 19.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:02 PM

    Is that with that script I pointed to?
    Which errors exactly?



  • 20.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:15 PM

    yeah in the script first 2 line it says no multible datacenter and it seems that it will still to all datacenter but cant keep up with it

     

    on the import script I need to use -permissions  yeah guess what I need to state the datacenter too now too and then it did merge our 4 datacenter is this one and rearanged the folder but I only did the -permissions and  not -folder

    so I gues I will do the handjob now move it back and make the permission that are missing too.

     

    still thanks for you help



  • 21.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:19 PM

    Ah, ok, didn't notice that (it's not my code).

    The 2nd issue is most probably a result of the 1st problem.



  • 22.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:36 PM

    yeah there are not really any scripts for that out there as I tried to google for vcenter with multible datacenter and only a copy of path + permissions on folders. the rest all worked just not that. For a Powershell noob

    Other scripts that do the whole migration, I tried it to just copy the things I needed but didnt work because they probably needed the whole code to run.



  • 23.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:41 PM

    I'll see if I can come up with something, but it might take some time.



  • 24.  RE: export and import permission between 2 vcenter

    Posted Apr 28, 2021 01:49 PM

    I don't think my colleagues find it that interesting to do that again because we migrated some ESX Hosts and the snaphot was 1 h old and we need to do that again and because of our faulty vcenter we have not that much time. So I think we just do the job without script