zoukankan      html  css  js  c++  java
  • Add the Multiple machines for the PVS Machine Catalog

    1. Create the PVS machine catalog:

    New-BrokerCatalog -AllocationType Random -CatalogKind PVS -Description "PVS Catalog Desc" -Name "PVS Catalog Name" -PvsAddress "xfpvsserver@xf.com" -PvsDomain "xf.com" -PvsForVM $($farmGuid:$schemeGuid) -MachinesArePhysical $false

    For the Server OS(MultiSession Support) as below:

    New-BrokerCatalog  -Name "PVS_catalog" -Description "PVS_catalog" -AllocationType "Random" -IsRemotePC $False -MachinesArePhysical $false -ProvisioningType "PVS" -SessionSupport "MultiSession"  -PvsAddress "xfpvsserver77@xf.local" -PvsDomain "xf.local" -PersistUserChanges "onLocal"

    2. Insert the machines data of devices in database:

    DECLARE @i INT,
    @num INT
    set @i=0
    set @num=1000
    while @i<@num
    BEGIN
        insert into ProvisioningServices.dbo.Device(
          [collectionId]
          ,[deviceName]
          ,[deviceMac]
          ,[port]
          ,[bootFrom]
          ,[authentication]
          ,[adTimestamp]
          ,[adSignature]
          ,[enabled]
          ,[domainName]
          ,[domainObjectSID]
          ,[domainControllerName]
          ,[domainTimeCreated]
          ,[type]
          ,[virtualHostingPoolId]
        )
    values ('EE8C7139-5175-4DF2-80EB-D8265198C630',
            'BaseNameTest'+CONVERT(varchar,@i),
            '777'+CONVERT(varchar,@i),
    
    '6901',
    '1',
    '0',
    '1526453339',
    '29094',
    '1',
    'xf.local',
    'S-1-5-21-4210597930-2839431311-553421094-2616',
    'W2K12R2-FU40LTO.xf.local',
    '2018-05-16 06:49:02.450',
    '0',
    'F8922DC7-7828-4796-B4C7-2FA81D64FE33'
            );
            SET @i=@i+1;
    END

    3. Import the machines id and name columns from database:

    #配置信息  
    $Database   = 'ProvisioningServices'  
    $Server     = 'xfPVSSERVER77'  
    $UserName   = 'sa'
    $Password   = '1qaz!QAZ'
     
    #创建连接对象
    $SqlConn = New-Object System.Data.SqlClient.SqlConnection
     
    #使用账号连接MSSQL
    $SqlConn.ConnectionString = "Data Source=$Server;Initial Catalog=$Database;user id=$UserName;pwd=$Password"
    
    # 确认状态
    $SqlConn.state; 
    
    #打开数据库连接  
    $SqlConn.open()  
    
    # 确认状态-again  
    $SqlConn.State;  
      
      
    # 确认切换到指定的数据库  
    $SqlConn.Database;  
    
    #查询显示
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.connection = $SqlConn
    $SqlCmd.commandtext = "select deviceid,devicename from ProvisioningServices.dbo.device where devicename like 'BaseNameSer%'"
    Write-Host $SqlCmd.commandtext
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $set = New-Object data.dataset
    $SqlAdapter.Fill($set)
    $path = "$env:USERPROFILEDesktopmachines.txt"
    $set.Tables[0] | Format-Table -Auto |Out-File -FilePath  $path
    $set.Tables[0] | Export-Csv "$env:USERPROFILEDesktopmachines_500.csv"
    
    #Write-Host "Just try"
    #foreach ($machine in $set.Tables[0])
    #{
    #    $machine.DeviceId
    #    $machine.DeviceName
    #    break
    #}
    #
    #foreach ($machine in $set.Tables[0]) {
    #        New-BrokerMachine -CatalogUid 1009 -MachineName $machine.DeviceName -HypervisorConnectionUid  1 -HostedMachineId $machine.DeviceId        
    #}
    
    
    
    

    4. New-BrokerMachine command to add the machines for the machine catalog:

    $machines = Import-Csv -Path $env:USERPROFILEDesktopmachines.csv
    foreach ($machine in $machines)
    {
        $machine.DeviceId
        $machine.DeviceName
        break
    }
    
    foreach ($machine in $machines) {
            New-BrokerMachine -CatalogUid 1003 -MachineName $machine.DeviceName -HypervisorConnectionUid  1 -HostedMachineId $machine.DeviceId        
    }
    
    
    
     

     

  • 相关阅读:
    1-27 awk 基本使用
    计算机网络(一)带宽
    CRC检错技术原理
    Wireshark漫谈(一)
    SQL字符串拼接
    MySQL学习笔记(二)
    MySQL学习笔记(一)
    Java 反射机制(二)
    Java 反射机制(一)
    Windows使用MySQL数据库管理系统中文乱码问题
  • 原文地址:https://www.cnblogs.com/Lina-zhu/p/9077471.html
Copyright © 2011-2022 走看看