powershell 使用PowerShell迁移vRealize业务组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 使用PowerShell迁移vRealize业务组相关的知识,希望对你有一定的参考价值。

<#
Usage:

1. Generate vra-businessgroups.json by running the following cloudclient command
   
   ./cloudclient.bat vra businessgroup list --export D:\vRAExports\vra-businessgroups.json --format "JSON"

2. Configure the variables and run this script to generate businessgroup-cloudclient-commands.ps1

3. Get a replace all of the machine prefix Ids in businessgroup-cloudclient-commands.ps1 with ones obtained from the new server

   ./cloudclient.bat vra machineprefix -list

4. Run businessgroup-cloudclient-commands.ps1

#>

#region Variables
$cloudClientPath = "D:\cloudclient\bin\cloudclient.bat"
$busunessGroupJsonFile = "vra-businessgroups.json"
$businessGroupScriptFile = "businessgroup-cloudclient-commands.ps1"
#endregion

#region functions
function Format-Users($users){

    if ($users){
        return $users -join ","   
        }

    }
#endregion

#region main
$businessGroups = Get-Content -Raw -Path "$($busunessGroupJsonFile)" | ConvertFrom-Json

$outFile = @()

foreach ($item in $businessGroups.Items){

    $params = @(

        "--name '" + $($item.Name) + "'"

        #Id AD Container is empty give it the value of None
        #In the UI this is not a mandetory field but CloudClient thinks it is
        if ($item.ActiveDirectoryContainer){
            "--adContainer '" + $($item.ActiveDirectoryContainer) + "'"
            }
        else {
            "--adContainer 'None'"
        }

        "--email '" + $($item.AdministratorEmail) + "'"

        "--machinePrefixId '" + $($item.MachinePrefixId) + "'"

        #If any of the below are empty, do not include the switch in $params
        if ($item.Administrators){
            "--admins '" + $(Format-Users($item.Administrators)) + "'"
            }

        if ($item.Support){
            "--support '" + $(Format-Users($item.Support)) + "'"
            }

        if ($item.Users){
            "--users '" + $(Format-Users($item.Users)) + "'"
            }

        )
 
    #Build each command and add it to the $outFile array
    $outFile += 'Invoke-Expression -Command "' + $($cloudClientPath) + ' vra businessgroup add ' + $($params) +'"'

    }

#Build the script file
$outFile | Set-Content -Path "$($businessGroupScriptFile)"
#end region

以上是关于powershell 使用PowerShell迁移vRealize业务组的主要内容,如果未能解决你的问题,请参考以下文章

powershell SNIP | VMware - TC迁移步骤

powershell 启用代码迁移 - 实体框架

如何使用PowerShell从VHD创建虚拟机

powershell 创建PowerShell脚本以完成由SickRage启动的解包过程,但通常会失败 - 这简化了大规模迁移到他们的

powershell SNIP | VMware - VM - 获取迁移详细信息(名称,数据存储,路径等)

Windows Server 2016-Powershell迁移FSMO角色