码迷,mamicode.com
首页 > 系统相关 > 详细

Add the Multiple machines for the PVS Machine Catalog

时间:2018-05-23 17:01:09      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:persist   col   cts   状态   test   file   use   -name   viso   

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:USERPROFILE\Desktop\machines.txt"
$set.Tables[0] | Format-Table -Auto |Out-File -FilePath  $path
$set.Tables[0] | Export-Csv "$env:USERPROFILE\Desktop\machines_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:USERPROFILE\Desktop\machines.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        
}



 

 

 

Add the Multiple machines for the PVS Machine Catalog

标签:persist   col   cts   状态   test   file   use   -name   viso   

原文地址:https://www.cnblogs.com/Lina-zhu/p/9077471.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!