> For the complete documentation index, see [llms.txt](https://docs.parallels.com/landing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.parallels.com/landing/ras-powershell-api-guide/v19/examples/publishing-example.md).

# Publishing Example

{% code fullWidth="true" %}

```powershell
#Establish a connection with Parallels RAS (Replace Administrator with your RAS root account). 
New-RASSession Administrator
###### FARM CONFIGURATION ######
#Add two RD Session Host servers. 
$RDS1 = New-RASRDS -Server "rds1.company.dom"
$RDS2 = New-RASRDS -Server "rds2.company.dom"
#Get the list of RD Session Host servers. 
$RDSList = Get-RASRDS

#Create a RAS RD Session Host group and add both RDS objects to it. 
$RDSGrp =  New-RASRDSGroup -Name "My RDS Group" -RDSObject $RDSList
#Update default settings used to configure RD Session Host agents. 
Set-RASRDSDefaultSettings -MaxSessions 100 -EnableAppMonitoring $true
###### PUBLISHING CONFIGURATION ######
#Add published folders to be used by different departments. 
$Fld_Acc = New-RASPubFolder -Name "AccDept" -Description "Accounting"
$Fld_Sales = New-RASPubFolder -Name "SalesDept" -Description "Sales"
#Add published desktops within their respective folders. 
$Desk_Acc = New-RASPubRDSDesktop -Name "AccPubDesktop" -ParentFolder $Fld_Acc -DesktopSize FullScreen -PublishFrom Group -PublishFromGroup $RDSGrp
$Desk_Sales = New-RASPubRDSDesktop -Name "SalesPubDesktop" -ParentFolder $Fld_Sales -DesktopSize Custom -Width 600 -Height 400 -PublishFrom All
#Add published applications within their respective folders. 
$App_Acc = New-RASPubRDSApp -Name "AccPubApp" -Target "C:\Windows\System32\calc.exe" -ParentFolder $Fld_Acc -PublishFrom All -WinType Maximized -StartOnLogon
$App_Sales = New-RASPubRDSApp -Name "SalesPubApp" -Target "C:\Windows\System32\notepad.exe" -ParentFolder $Fld_Sales -PublishFrom Server -PublishFromServer $RDS1
#Update default settings used to configure published resources. 
Set-RASPubDefaultSettings -CreateShortcutOnDesktop $true
#Override shortcut default settings for a specific published application. 
Set-RASPubRDSApp -InputObject $App_Sales -InheritShorcutDefaultSettings $false -CreateShortcutOnDesktop $false
###### PUB FILTERING CONFIGURATION ######
#Set AD account filters by ID. 
Add-RASRule -Id $Desk_Acc.Id -ObjType PubItem -RuleName "Rule 1"
$Desk_Acc_Rules = Get-RASRule -Id $Desk_Acc.Id -ObjType PubItem

Set-RASCriteria -Id $Desk_Acc.Id -ObjType PubItem -SecurityPrincipalsEnabled $true -RuleId $Desk_Acc_Rules[0].Id

Add-RASCriteriaSecurityPrincipal -Id $Desk_Acc.Id -ObjType PubItem -RuleId $Desk_Acc_Rules[0].Id -Account "Guests"
#Set AD account filters by object. 
Add-RASCriteriaSecurityPrincipal -Id $Desk_Acc.Id -ObjType PubItem -RuleId $Desk_Acc_Rules[0].Id -SID "S-1-5-11"
#Set an IP filter (with range) on application. 
Add-RASRule -InputObject $App_Acc -RuleName "Rule 1"
$App_Acc_Rules = Get-RASRule -Id $App_Acc.Id -ObjType PubItem

Set-RASCriteria -InputObject $App_Acc -RuleId $App_Acc_Rules[0].Id -IPsEnabled $true

Add-RASCriteriaIP -InputObject $App_Acc -RuleId $App_Acc_Rules[0].Id -IPType Version4 -IP "10.0.0.1-10.0.0.12"
#Apply all settings. This cmdlet performs the same action as the Apply button in the RAS console. 
Invoke-RASApply
#End the current RAS session. 
Remove-RASSession
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.parallels.com/landing/ras-powershell-api-guide/v19/examples/publishing-example.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
