1. Create the PVS machine catalog:
New-BrokerCatalog -AllocationType Random -CatalogKind PVS -Description "PVS Catalog Desc" -Name "PVS Catalog Name" -PvsAddress "[email protected]" -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 "[email protected]" -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 }
原文地址:https://www.cnblogs.com/Lina-zhu/p/9077471.html
时间: 2024-10-15 04:39:26