• Add the Multiple machines for the MCS Machine Catalog


    1. Create the MCS type machine catalog

    New-BrokerCatalog -name 'TestCatalog' -ProvisioningType 'MCS' -SessionSupport 'MuiltiSession' -PersistUserChanges 'onlocal'

    2. Add the machine to MCS machine catalog

    $password = "1qaz!QAZ"
    $securepassword = $Password | ConvertTo-SecureString -AsPlainText -Force
    $ADAccount = New-AcctADAccount -IdentityPoolName MCS_catalog2 -Count 180 -OutVariable result -ADUserName "xfadministrator" -ADPassword $SecurePassword
    $machines = $ADAccount.SuccessfulAccounts
    Foreach($machine in $machines)
    {
        $VMName = $machine | select ADAccountName       
        New-provVM -ProvisioningSchemeName "MCS_catalog2" -ADAccountName $VMName.ADAccountName    
        #$provVM = Get-provVM |select ADAccountName,VMId |Where-Object{$_.ADAccountName -like $VMName}    
        New-BrokerMachine -CatalogUid 6 -MachineName $VMName.ADAccountName 
    }
    

    3.Delete the machine from XenServer host

    for ($i=0; $i -le 3600000; $i++)
    {
            start-sleep -seconds 3
            $i
    Connect-XenServer -url "http://10.150.182.76" -UserName "root" -Password "9JdUl63w3Unf" -NoWarnCertificates -SetDefaultSession

    $myVms = Get-XenVM | select name_label| Where-Object {$_.name_label -like "fwmachine*"}
    for($j = 0; $j -lt $myVms.length-1; $j++){ 
            $number1 = $myVms[$j].name_label.substring(9)
            $number2 = $myVms[$myVms.length-1].name_label.substring(9)
            if ($number1 -lt $number2){
                $delVm = $myVms[$j].name_label      
            }else{
                $delVm = $myVms[$myVms.length-1].name_label
            }  
                 $delVm   
                 Remove-XenVM -Name $delVm
    
          }
                   
    }

     4.Delete the vdisk from xenserver

    Connect-XenServer -url "http://10.150.182.76" -UserName "root" -Password "9JdUl63w3Unf" -NoWarnCertificates -SetDefaultSession
    
    Get-XenVDI -Name fwmachine* | Remove-XenVDI
  • 相关阅读:
    码云非活跃帐号处理规范
    css 利用animation和transform 设置鸭子表
    css 背景图片
    css 利用transform 实现页面居中效果
    css 表格
    利用雪碧图,完成兔子走路过渡/动画效果
    Apache 2.0.50,+php5.1.2+mysql 5.1 安装手记
    PHP企业级应用之WebService篇(转)
    发个C语言连接Postgresql程序(转)
    array 和 xml 相互转换
  • 原文地址:https://www.cnblogs.com/Lina-zhu/p/9115659.html
Copyright © 2020-2023  润新知