Skip to content

Commit

Permalink
Updated Samples to latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrech committed Sep 3, 2024
1 parent 3b44661 commit a74526c
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Samples/BasicSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ New-RASGateway -Server $GWServer

#Add an RD Session Host server.
log "Adding new RD Session Host server"
New-RASRDS -Server $RDSServer
New-RASRDSHost -Server $RDSServer

#Add a published desktop.
log "Adding new RDS published desktop"
Expand Down
12 changes: 6 additions & 6 deletions Samples/FarmSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ New-RASGateway -Server $GWServer
#Add the first RD Session Host server
#The $RDS1 variable receives an object of type RDS identifying the RD Session Host.
log "Adding the first RD Session Host server"
$RDS1 = New-RASRDS -Server $RDSServer1
$RDS1 = New-RASRDSHost -Server $RDSServer1

#Update the description of RD Session Host specified by the $RDS1 variable.
log "Updating the RD Session description"
Set-RASRDS -InputObject $RDS1 -Description $RDS1Desc
Set-RASRDSHost -InputObject $RDS1 -Description $RDS1Desc

#Add the second RD Session Host.
log "Adding the second RD Session Host server"
$RDS2 = New-RASRDS -Server $RDSServer2
$RDS2 = New-RASRDSHost -Server $RDSServer2

#Get the list of RD Session Host servers. The $RDSList variable receives an array of objects of type RDS.
log "Retrieving the list of RD Session servers"
$RDSList = Get-RASRDS
$RDSList = Get-RASRDSHost

log "Print the list of RD Session servers retrieved"
Write-Host ($RDSList | Format-Table | Out-String)

#Create an RD Session Host Group and add both RD Session Host objects to it.
log "Add an RD Session host group (with list of RD Sessions)"
New-RASRDSGroup -Name $RDSGroupName -RDSObject $RDSList
New-RASRDSHostPool -Name $RDSGroupName -RDSObject $RDSList

#Add the third RD Session Host server.
log "Adding the third RD Session Host server"
$RDS3 = New-RASRDS -Server $RDSServer3
$RDS3 = New-RASRDSHost -Server $RDSServer3

#Move the RD Session host to an existing RDS Group.
log "Move the RD Session host to an existing RDS Group"
Expand Down
4 changes: 2 additions & 2 deletions Samples/GradualPowerOff.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ log "Connecting with RAS Licensing server"
New-RASSession -Username $RASAdminUsername -Password $RASAdminPassword

log "Retrieving list of Servers in '$RDSGroupName'"
$RDSGroupMembers = Get-RASRDSGroupMember -GroupName $RDSGroupName
$RDSGroupMembers = Get-RASRDSHostPoolMember -HostPoolName $RDSGroupName

log "Sort Server by ID"
$SortedRDSGroupMembers = [System.Collections.ArrayList] ($RDSGroupMembers | Sort-Object -Property Id)
Expand All @@ -66,7 +66,7 @@ For ($i=0; $i -lt $IgnoreServerCount; $i++) {
}

log "Retrieving RDS Status"
$RDSStatusList = Get-RASRDSStatus
$RDSStatusList = Get-RASRDSHostStatus

log "Checking Sessions on RDS Machines"
ForEach ($RDS in $SortedRDSGroupMembers) {
Expand Down
4 changes: 2 additions & 2 deletions Samples/GradualPowerOn.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ log "Connecting with RAS Licensing server"
New-RASSession -Username $RASAdminUsername -Password $RASAdminPassword

log "Retrieving list of Servers in '$RDSGroupName'"
$RDSGroupMembers = Get-RASRDSGroupMember -GroupName $RDSGroupName
$RDSGroupMembers = Get-RASRDSHostPoolMember -HostPoolName $RDSGroupName

log "Sort Server by ID"
$SortedRDSGroupMembers = [System.Collections.ArrayList] ($RDSGroupMembers | Sort-Object -Property Id)

log "Retrieving RDS Status"
$RDSStatusList = Get-RASRDSStatus
$RDSStatusList = Get-RASRDSHostStatus

$TotalMachinesOn = 0
$TotalActiveSessions = 0
Expand Down
4 changes: 2 additions & 2 deletions Samples/InitialPowerOn.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ log "Connecting with RAS Licensing server"
New-RASSession -Username $RASAdminUsername -Password $RASAdminPassword

log "Retrieving list of Servers in '$RDSGroupName'"
$RDSGroupMembers = Get-RASRDSGroupMember -GroupName $RDSGroupName
$RDSGroupMembers = Get-RASRDSHostPoolMember -HostPoolName $RDSGroupName

log "Sort Server by ID"
$SortedRDSGroupMembers = [System.Collections.ArrayList] ($RDSGroupMembers | Sort-Object -Property Id)
Expand All @@ -61,7 +61,7 @@ $BootServerCount = [int]($SortedRDSGroupMembers.Count / 100 * $BootServerPercen
Log "Booting $BootServerCount RDS Servers:"

log "Retrieving RDS Status"
$RDSStatusList = Get-RASRDSStatus
$RDSStatusList = Get-RASRDSHostStatus

For ($i=0; $i -lt $BootServerCount; $i++) {
$RDS = $SortedRDSGroupMembers[0]
Expand Down
10 changes: 6 additions & 4 deletions Samples/PublishingSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $RDSServer2 = "rds2.company.dom" #(replace 'rds2.company.dom' with a valid FQDN
$RDSGroupName = "My RDS Group" #(replace with a more specific name).
$RDSDefSettMaxSessions = 100 #(replace default value with preferred max sessions).
$RDSDefSettAppMonitor = $true #(replace default value with preferred App Monitoring value (Enabeld/Disabled)).
$VMNameFormat = "Win10-%ID:3%"

$AccFldName = "AccDept"
$AccFldDesc = "Accounting"
Expand Down Expand Up @@ -62,19 +63,20 @@ New-RASSession

#Add two RD Session Host servers.
log "Adding two RD Session host servers"
$RDS1 = New-RASRDS -Server $RDSServer1
$RDS2 = New-RASRDS -Server $RDSServer2
$RDS1 = New-RASRDSHost -Server $RDSServer1
$RDS2 = New-RASRDSHost -Server $RDSServer2

#Get the list of RD Session Host servers. The $RDSList variable receives an array of objects of type RDS.
log "Retrieving the list of RD Session servers"
$RDSList = Get-RASRDS
$RDSList = Get-RASRDSHost

log "Print the list of RD Session servers retrieved"
Write-Host ($RDSList | Format-Table | Out-String)

#Create an RD Session Host Group and add both RD Session Host objects to it.
log "Add an RD Session host group (with list of RD Sessions)"
$RDSGrp = New-RASRDSGroup -Name $RDSGroupName -RDSObject $RDSList
New-RASRDSHostPool -Name $RDSGroupName -Description "RDSTemplates Pool" -WorkLoadThreshold 50 -ServersToAddPerRequest 2 `
-WorkLoadToDrain 20 -HostsToCreate 1 -HostName $VMNameFormat -MinServersFromTemplate 2 -MaxServersFromTemplate 2 -Autoscale $true -RDSObject $RDSList

#Update default settings used to configure RD Session Host agents.
log "Updating RDS default settings"
Expand Down
4 changes: 2 additions & 2 deletions Samples/RASAgentSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ New-RASSession

#Add two RD Session Host servers.
log "Adding two RD Session host servers"
$rds = New-RASRDS -Server $RDSServer1
New-RASRDS -Server $RDSServer2
$rds = New-RASRDSHost -Server $RDSServer1
New-RASRDSHost -Server $RDSServer2

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Expand Down
49 changes: 25 additions & 24 deletions Samples/RDSTemplateSample.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## ==================================================================
##
## Copyright (c) 2005-2019 Parallels Software International, Inc.
## Copyright (c) 2005-2024 Parallels Software International, Inc.
## Released under the terms of MIT license (see LICENSE for details)
##
## ==================================================================
Expand All @@ -9,7 +9,7 @@
.SYNOPSIS
RAS PowerShell RDSTemplate Sample
.DESCRIPTION
Demonstrates how to add a Provider, and use RDS Templates in RDS Groups.
Demonstrates how to add a Provider, and use RDS Templates in RDS Host Pool.
.NOTES
File Name : RDSTemplateSample.ps1
Author : www.parallels.com
Expand All @@ -24,17 +24,17 @@
)

#Pre-set Params
$VDIServer = "vdi.company.dom" #(replace 'vdi.company.dom' with a valid FQDN, computer name, or IP address).
$VDIAgent = "vdiagent.company.dom" #(replace 'vdiagent.company.dom' with a valid FQDN, computer name, or IP address).
$VMID = "564d5e6f-3fad-bcf9-7c6b-bac9f212713d" #(replace with a valid virtual machine ID)
$TemplateName = "Win10template"
$VMNameFormat = "Win10-%ID:3%"
$Owner = "Owner"
$Organization = "Parallels"
$Domain = "company.dom"
$TargetOU = "OU=VDI,DC=dom,DC=company"
$ComputerName = "10.0.0.51"
$RDSGroupName = "My RDS Group" #(replace with a more specific name).
$VDIServer = "vdi.company.dom" #(replace 'vdi.company.dom' with a valid FQDN, computer name, or IP address).
$VDIAgent = "vdiagent.company.dom" #(replace 'vdiagent.company.dom' with a valid FQDN, computer name, or IP address).
$VMID = "564d5e6f-3fad-bcf9-7c6b-bac9f212713d" #(replace with a valid virtual machine ID)
$TemplateName = "Win10template"
$VMNameFormat = "Win10-%ID:3%"
$Owner = "Owner"
$Organization = "Parallels"
$Domain = "company.dom"
$TargetOU = "OU=VDI,DC=dom,DC=company"
$ComputerName = "10.0.0.51"
$RDSHostPoolName = "My RDS Host Pool" #(replace with a more specific name).


#Configure logging
Expand All @@ -54,7 +54,7 @@ New-RASSession

#Add a Provider.
log "Adding a new Provider"
$Provider = New-RASProvider -Server $VDIServer -Type VmwareESXi6_0 -VDIUsername root -VDIAgent $VDIAgent -Username $AdminUsername -Password $AdminPassword
$Provider = New-RASProvider -Server $VDIServer VMwareESXi -VmwareESXiVersion v6_5 -ProviderUsername root -ProviderPassword $AdminPassword -VDIAgent $VDIAgent -Username $AdminUsername -Password $AdminPassword

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Expand All @@ -67,20 +67,22 @@ Get-RASVM -ProviderId $Provider.Id

#Convert a VM to an RDSTemplate
log "Converting the VM to an RDSTemplate"
$rdsTemplate = New-RASVDITemplate -ProviderId $Provider.Id -VMId $VMID -Name $TemplateName -VMNameFormat $VMNameFormat -MaxVMs 5 -PreCreatedVMs 2 -VMsToCreate 1 `
-ImagePrepTool RASPrep -OwnerName $Owner -Organization $Organization -Domain $Domain -CloneMethod LinkedClone -TargetOU $TargetOU -TemplateType RDSH -ComputerName $ComputerName
$rdsTemplate = New-RASTemplate -ObjType RDSTemplate -ProviderId $Provider.Id -VMId $VMID -Name $TemplateName -ImagePrepTool RASPrep -OwnerName $Owner -Administrator $AdminUsername -AdminPassword $AdminPassword `
-Organization $Organization -Domain $Domain -DomainPassword $AdminPassword -CloneMethod LinkedClone -DomainOrgUnit $TargetOU -ComputerName $ComputerName

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Invoke-RASApply

#Get Template Version
log "Getting RDS Template Version"
$rdsTemplateVersion = Get-RASTemplateVersion -TemplateId $rdsTemplate.Id -ObjType RDSTemplateVersion

###### RDS GROUP CONFIGURATION ######

#Create an RD Session Host Group and add RDS Template object to it.
log "Add an RD Session host group (with list of RD Sessions)"
New-RASRDSGroup -Name $RDSGroupName -Description "RDSTemplates Group" -UseRASTemplate -RASTemplate $rdsTemplate -WorkLoadThreshold 50 -ServersToAddPerRequest 2 `
-MaxServersFromTemplate 2 -WorkLoadToDrain 20
###### RDS HOST POOL CONFIGURATION ######
#Create an RD Session Host pool and add RDS Template object to it.
log "Add an RD Session host pool (with list of RD Sessions)"
New-RASRDSHostPool -Name $RDSHostPoolName -Description "RDSTemplates Pool" -RASTemplate $rdsTemplate -RASTemplateVersionId $rdsTemplateVersion.Id -WorkLoadThreshold 50 -ServersToAddPerRequest 2 `
-WorkLoadToDrain 20 -HostsToCreate 1 -HostName $VMNameFormat -MinServersFromTemplate 2 -MaxServersFromTemplate 2 -Autoscale $true

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Expand All @@ -90,5 +92,4 @@ Invoke-RASApply
log "Ending RAS session"
Remove-RASSession

log "All Done"

log "All Done"
4 changes: 2 additions & 2 deletions Samples/StatusInfoSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ New-RASSession

#Adding a RAS RDS
log "Adding new RD Session Host server"
New-RASRDS -Server $RDSServer
New-RASRDSHost -Server $RDSServer

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Expand All @@ -63,7 +63,7 @@ Start-Sleep -Seconds 5

# Get RDS status info
log "Getting RAS RD Session host status information"
Get-RASRDSStatus -Server $RDSServer
Get-RASRDSHostStatus -Server $RDSServer


###### Secure Gateway status info ######
Expand Down
40 changes: 15 additions & 25 deletions Samples/VDISample.ps1 → Samples/VDITemplateSample.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## ==================================================================
##
## Copyright (c) 2005-2019 Parallels Software International, Inc.
## Copyright (c) 2005-2024 Parallels Software International, Inc.
## Released under the terms of MIT license (see LICENSE for details)
##
## ==================================================================

<#
.SYNOPSIS
RAS PowerShell VDI Examples
RAS PowerShell VDI Template Examples
.DESCRIPTION
Examples to demonstrates how to add a Provider, and publish a desktop from a VDI Template.
.NOTES
File Name : VDISample.ps1
File Name : VDITemplateSample.ps1
Author : www.parallels.com
.EXAMPLE
.\VDISample.ps1
.\VDITemplateSample.ps1
#>

[CmdletBinding()]
Expand All @@ -28,22 +28,20 @@ $VDIServer = "vdi.company.dom" #(replace 'vdi.company.dom' with a
$VDIAgent = "vdiagent.company.dom" #(replace 'vdiagent.company.dom' with a valid FQDN, computer name, or IP address).
$VMID = "564d5e6f-3fad-bcf9-7c6b-bac9f212713d" #(replace with a valid virtual machine ID)
$TemplateName = "Win10template"
$VMNameFormat = "Win10-%ID:3%"
$VMNameFormat = "Win10-%ID:3%"
$Owner = "Owner"
$Organization = "Parallels"
$Domain = "company.dom"
$TargetOU = "OU=VDI,DC=dom,DC=company"
$PubDeskName = "VDIDesktop"


#Configure logging
function log
{
param([string]$message)
"`n`n$(get-date -f o) $message"
}


Import-Module RASAdmin

#Establish a connection with Parallels RAS (NB. User will be prompted for Username and Password)
Expand All @@ -54,39 +52,31 @@ New-RASSession

#Add a Provider.
log "Adding a new Provider"
$Provider = New-RASProvider -Server $VDIServer -VMwareESXi -VMwareESXiVersion v6_5 -VDIAgent $VDIAgent -VDIUsername root -VDIPassword $AdminPassword -Name "vdi"

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Invoke-RASApply
$Provider = New-RASProvider -Server $VDIServer -VMwareESXi -VMwareESXiVersion v6_5 -VDIAgent $VDIAgent -ProviderUsername root -ProviderPassword $AdminPassword -Name "vdi"

#Get the list of Virtual Machines through the RAS Provider Agent
### NB. Make sure to allow some time before calling Get-RASVM, to let the host agent successfully connect ###
log "Getting the list of virtual machines through the RAS Provider Agent"
Get-RASVM -ProviderId $Provider.Id


#Create a new RAS VDI Template
log "Create a new RAS VDI Template"
$vmTemplate = New-RASVDITemplate -ProviderId $Proivder.Id -VMId $VMID -Name $TemplateName -VMNameFormat $VMNameFormat `
-MaxVMs 5 -PreCreatedVMs 2 -ImagePrepTool RASPrep -OwnerName $Owner -Organization $Organization -Domain $Domain -CloneMethod LinkedClone -TargetOU $TargetOU -Administrator $AdminUsername -DomainPassword $AdminPassword -AdminPassword $AdminPassword
#Add a new VDI Pool
log "Add a new VDI Pool"
$VDIPool = New-RASVDIPool -Name "VDIPool"
$vmTemplate = New-RASTemplate -ProviderId $Provider.Id -VMId $VMID -Name $TemplateName -ImagePrepTool RASPrep -OwnerName $Owner -Organization $Organization -Domain $Domain `
-CloneMethod LinkedClone -DomainPassword $AdminPassword -Administrator $AdminUsername -AdminPassword $AdminPassword -ObjType VDITemplate -DomainOrgUnit $TargetOU

#Add a new VDI Pool Member (TemplateDesktop)
log "Add a new VDI Pool Member (TemplateDesktop)"
Add-RASVDIPoolMember -VDIPoolId $VDIPool.Id -Type TemplateDesktop -Name $vmTemplate.Name -VDITemplateId $vmTemplate.Id
#Add a new VDI Host Pool
log "Add a new VDI Pool"
$VDIHostPool = New-RASVDIHostPool -Name "VDIPool" -MaxHosts 5 -PreCreatedHosts 2 -HostName $VMNameFormat -ProvisioningType Template -TemplateId $vmTemplate.Id

#Add a new VDI Pool Member (Desktop)
log "Add a new VDI Pool Member (Desktop)"
Add-RASVDIPoolMember -VDIPoolName "My VDI Pool" -Type Desktop -Name "MY VDI Pool Member" -ProviderId $Provider.Id -VMId $VMID
#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Invoke-RASApply

###### PUBLISHING CONFIGURATION ######

#Add published desktop making use of the VDI Template.
log "Adding published desktop using the VDI template"
New-RASPubVDIDesktop -Name $PubDeskName -ConnectTo SpecificRASTemplate -VDITemplate $vmTemplate -Persistent $true
New-RASPubVDIDesktop -Name $PubDeskName -ConnectTo AnyGuest -VDITemplateId $vmTemplate.Id -VDIHostPoolId $VDIHostPool.Id -Persistent $true

#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console.
log "Appling settings"
Expand Down

0 comments on commit a74526c

Please sign in to comment.