﻿<Activity mc:Ignorable="sads sap" x:Class="RDManagement.New_RDSHCollection" this:New_RDSHCollection.User="[{&quot;Domain Users&quot;}]" this:New_RDSHCollection.EnableUserDisk="False"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mpa="clr-namespace:Microsoft.PowerShell.Activities;assembly=Microsoft.PowerShell.Activities"
 xmlns:mpma="clr-namespace:Microsoft.PowerShell.Management.Activities;assembly=Microsoft.PowerShell.Management.Activities"
 xmlns:mpua="clr-namespace:Microsoft.PowerShell.Utility.Activities;assembly=Microsoft.PowerShell.Utility.Activities"
 xmlns:mrc="clr-namespace:Microsoft.RemoteDesktopServices.Common;assembly=Microsoft.RemoteDesktopServices.Management.Activities"
 xmlns:mrma="clr-namespace:Microsoft.RemoteDesktopServices.Management.Activities;assembly=Microsoft.RemoteDesktopServices.Management.Activities"
 xmlns:mrmc="clr-namespace:Microsoft.RemoteDesktopServices.Management.Cmdlets;assembly=Microsoft.RemoteDesktopServices.Management.Activities"
 xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
 xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
 xmlns:s="clr-namespace:System;assembly=mscorlib"
 xmlns:s1="clr-namespace:System;assembly=System"
 xmlns:s2="clr-namespace:System;assembly=System.Xml"
 xmlns:s3="clr-namespace:System;assembly=System.Core"
 xmlns:s4="clr-namespace:System;assembly=System.ServiceModel"
 xmlns:s5="clr-namespace:System;assembly=System.ComponentModel.Composition"
 xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"
 xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sc="clr-namespace:System.Collections;assembly=mscorlib"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System"
 xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
 xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
 xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
 xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
 xmlns:sm="clr-namespace:System.Management;assembly=System.Management"
 xmlns:sma="clr-namespace:System.Management.Automation;assembly=System.Management.Automation"
 xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
 xmlns:this="clr-namespace:RDManagement"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="RDManagementServer" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="CollectionAlias" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="Name" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="Description" Type="InArgument(x:String)" />
    <x:Property Name="User" Type="InArgument(s:String[])" />
    <x:Property Name="RDSHServer" Type="InArgument(s:String[])">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="EnableUserDisk" Type="InArgument(x:Boolean)" />
    <x:Property Name="UserVHDShare" Type="InArgument(x:String)" />
    <x:Property Name="DiskSize" Type="InArgument(x:Int64)" />
  </x:Members>
  <this:New_RDSHCollection.Description>
    <InArgument x:TypeArguments="x:String">
      <Literal x:TypeArguments="x:String" Value="" />
    </InArgument>
  </this:New_RDSHCollection.Description>
  <sap:VirtualizedContainerService.HintSize>5006,2463</sap:VirtualizedContainerService.HintSize>
  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
  <Sequence DisplayName="Create RDSH Collection" sap:VirtualizedContainerService.HintSize="4966,2423">
    <Sequence.Variables>
      <Variable x:TypeArguments="sma:PSDataCollection(sma:ErrorRecord)" Name="errors" />
      <Variable x:TypeArguments="sma:PSDataCollection(sma:PSObject)" Name="Null" />
      <Variable x:TypeArguments="x:Int32" Default="1" Modifiers="ReadOnly" Name="CBProgressID" />
      <Variable x:TypeArguments="x:Int32" Default="2" Modifiers="ReadOnly" Name="RDSHProgressID" />
      <Variable x:TypeArguments="x:Int32" Default="0" Name="CurrentProgress" />
      <Variable x:TypeArguments="sma:ErrorRecord" Name="catchErrorRecord" />
      <Variable x:TypeArguments="x:Int32" Default="0" Name="RemapMode" />
      <Variable x:TypeArguments="x:Int32" Default="1" Name="DiskType" />
      <Variable x:TypeArguments="x:String" Name="variable2" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <mpua:WriteProgress Activity="New-RDSHCollection" DisplayName="Progress : 0" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="0" ProgressId="[CBProgressID]" Status="In Progress..." />
    <mpua:WriteVerbose DisplayName="Verbose: Input" sap:VirtualizedContainerService.HintSize="4944,22" Message="[&quot;Management Server: &quot; + RDManagementServer + Environment.NewLine +&#xA;&quot;Collection Alias: &quot; + CollectionAlias + Environment.NewLine +&#xA;&quot;Collection Name: &quot; + Name + Environment.NewLine +&#xA;&quot;RDSH Servers: &quot; + (String.Join(&quot;, &quot;, RDSHServer)) + Environment.NewLine +&#xA;&quot;Allowed Users: &quot; + String.Join(&quot;, &quot;, User) + Environment.NewLine +&#xA;&quot;Description: &quot; + Description]" />
    <mpua:WriteProgress Activity="New-RDSHCollection" DisplayName="Progress : 10" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="10" ProgressId="[CBProgressID]" Status="In Progress..." />
    <If Condition="[String.IsNullOrEmpty(Description)]" sap:VirtualizedContainerService.HintSize="4944,208">
      <If.Then>
        <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement;&#xA;New-RDSHPool -Name $using:Name -Alias $using:CollectionAlias -User $using:User -ManagementServer $using:RDManagementServer -ActivityId  $using:CBProgressID" DisplayName="Create Collection on Broker" sap:VirtualizedContainerService.HintSize="913,98" PSError="[errors]" />
      </If.Then>
      <If.Else>
        <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement;&#xA;New-RDSHPool -Name $using:Name -Alias $using:CollectionAlias -User $using:User -Description $using:Description -ManagementServer $using:RDManagementServer -ActivityId  $using:CBProgressID" DisplayName="Create Collection on Broker" sap:VirtualizedContainerService.HintSize="1082,98" PSError="[errors]" />
      </If.Else>
    </If>
    <If Condition="[errors.Count &lt;&gt; 0]" DisplayName="Quit If Error" sap:VirtualizedContainerService.HintSize="4944,208">
      <If.Then>
        <TerminateWorkflow Exception="[errors(0).Exception]" sap:VirtualizedContainerService.HintSize="200,22" />
      </If.Then>
    </If>
    <mpua:WriteProgress Activity="New-RDSHCollection" DisplayName="Progress : 40" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="40" ProgressId="[CBProgressID]" Status="In Progress..." />
    <mpua:WriteProgress Activity="New-RDSHCollection" DisplayName="Progress : 0" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="0" ProgressId="[RDSHProgressID]" Status="In Progress..." />
    <ForEach x:TypeArguments="x:String" DisplayName="Configure RDSH servers" sap:VirtualizedContainerService.HintSize="4944,1216" Values="[RDSHServer]">
      <ActivityAction x:TypeArguments="x:String">
        <ActivityAction.Argument>
          <DelegateInArgument x:TypeArguments="x:String" Name="server" />
        </ActivityAction.Argument>
        <Sequence sap:VirtualizedContainerService.HintSize="4914,1108">
          <Sequence.Variables>
            <Variable x:TypeArguments="sma:PSDataCollection(sma:ErrorRecord)" Default="[New PSDataCollection(Of ErrorRecord)()]" Name="LoopErrors1" />
            <Variable x:TypeArguments="sma:PSDataCollection(sma:ErrorRecord)" Default="[New PSDataCollection(Of ErrorRecord)()]" Name="LoopErrors2" />
            <Variable x:TypeArguments="x:String" Name="serverDomain" />
            <Variable x:TypeArguments="x:String" Name="serverNetbios" />
          </Sequence.Variables>
          <sap:WorkflowViewStateService.ViewState>
            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
              <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            </scg3:Dictionary>
          </sap:WorkflowViewStateService.ViewState>
          <Assign sap:VirtualizedContainerService.HintSize="4892,60">
            <Assign.To>
              <OutArgument x:TypeArguments="x:String">[serverDomain]</OutArgument>
            </Assign.To>
            <Assign.Value>
              <InArgument x:TypeArguments="x:String">[Microsoft.RemoteDesktopServices.Common.CommonUtility.GetDomainNameFromLiveComputer(server)]</InArgument>
            </Assign.Value>
          </Assign>
          <Assign sap:VirtualizedContainerService.HintSize="4892,60">
            <Assign.To>
              <OutArgument x:TypeArguments="x:String">[serverNetbios]</OutArgument>
            </Assign.To>
            <Assign.Value>
              <InArgument x:TypeArguments="x:String">[Microsoft.RemoteDesktopServices.Common.CommonUtility.GetNetbiosNameFromLiveComputer(Server)]</InArgument>
            </Assign.Value>
          </Assign>
          <TryCatch sap:VirtualizedContainerService.HintSize="4892,784">
            <TryCatch.Try>
              <Sequence sap:VirtualizedContainerService.HintSize="4874,597">
                <sap:WorkflowViewStateService.ViewState>
                  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                  </scg3:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
                <mpa:InlineScript Command="function Add-SecurityGroupMember { param ( [Parameter(Mandatory=$TRUE)] [string] $GroupSID, [Parameter(Mandatory=$TRUE)] [string[]] $Member, [switch] $IsComputer ) try { $sid = New-Object System.Security.Principal.SecurityIdentifier $GroupSID; $groupName = $sid.Translate([System.Security.Principal.NTAccount]).Value.split('\')[1]; $directoryEntry = [ADSI]('WinNT://{0}/{1},group' -f $Env:COMPUTERNAME, $groupName) } catch { throw $_ };  foreach($entry in $Member) { $memberPath = 'WinNT:/'; $parts = $entry -split '\\'; foreach ($part in $parts) { $memberPath = $memberPath + '/' + $part; }; if ($IsComputer) { $memberPath = $memberPath + '$' }; $directoryEntry.Invoke('Add', $memberPath); } }; $memberComputer = $using:serverDomain + '\' + $using:serverNetbios; Add-SecurityGroupMember -GroupSID 'S-1-5-32-576' -Member $memberComputer -IsComputer -ErrorAction Silentlycontinue" DisplayName="Add RDSH Servers to 'End point servers' " sap:VirtualizedContainerService.HintSize="4852,96" PSComputerName="[{RDManagementServer}]" PSError="[LoopErrors1]" Result="[Null]" />
                <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="4852,246">
                  <sap:WorkflowViewStateService.ViewState>
                    <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                      <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                    </scg3:Dictionary>
                  </sap:WorkflowViewStateService.ViewState>
                  <Assign sap:VirtualizedContainerService.HintSize="242,60">
                    <Assign.To>
                      <OutArgument x:TypeArguments="x:Int32">[CurrentProgress]</OutArgument>
                    </Assign.To>
                    <Assign.Value>
                      <InArgument x:TypeArguments="x:Int32">[CurrentProgress + (20 \ RDSHServer.Length)]</InArgument>
                    </Assign.Value>
                  </Assign>
                  <mpua:WriteProgress Activity="Add-RDSessionHost" DisplayName="Progress : Current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[RDSHProgressID]" Status="In Progress..." />
                </Sequence>
                <If Condition="[LoopErrors1.Count &lt;&gt; 0]" DisplayName="Write RDMS Error" sap:VirtualizedContainerService.HintSize="4852,51">
                  <sap:WorkflowViewStateService.ViewState>
                    <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                      <x:Boolean x:Key="IsExpanded">False</x:Boolean>
                      <x:Boolean x:Key="IsPinned">False</x:Boolean>
                    </scg3:Dictionary>
                  </sap:WorkflowViewStateService.ViewState>
                  <If.Then>
                    <Sequence sap:VirtualizedContainerService.HintSize="286,656">
                      <sap:WorkflowViewStateService.ViewState>
                        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                        </scg3:Dictionary>
                      </sap:WorkflowViewStateService.ViewState>
                      <Sequence sap:VirtualizedContainerService.HintSize="264,246">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                          </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <Assign sap:VirtualizedContainerService.HintSize="242,60">
                          <Assign.To>
                            <OutArgument x:TypeArguments="sma:ErrorRecord">[catchErrorRecord]</OutArgument>
                          </Assign.To>
                          <Assign.Value>
                            <InArgument x:TypeArguments="sma:ErrorRecord">[ErrorUtility.GetErrorRecord(RDManagementResources.ResourceManager.GetString("FailedToSetSessionHostObjects"), server, ErrorId.ConfigureRDSessionHost, 2, LoopErrors1(0).Exception)]</InArgument>
                          </Assign.Value>
                        </Assign>
                        <mpua:WriteError DisplayName="Write-Error" ErrorRecord="[catchErrorRecord]" sap:VirtualizedContainerService.HintSize="242,22" />
                      </Sequence>
                      <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="264,246">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                          </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <Assign sap:VirtualizedContainerService.HintSize="242,60">
                          <Assign.To>
                            <OutArgument x:TypeArguments="x:Int32">[CurrentProgress]</OutArgument>
                          </Assign.To>
                          <Assign.Value>
                            <InArgument x:TypeArguments="x:Int32">[CurrentProgress + (80 \ RDSHServer.Length)]</InArgument>
                          </Assign.Value>
                        </Assign>
                        <mpua:WriteProgress Activity="Add-RDSessionHost" DisplayName="Progress : Current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[RDSHProgressID]" Status="In Progress..." />
                      </Sequence>
                    </Sequence>
                  </If.Then>
                  <If.Else>
                    <Sequence DisplayName="Configure RD Session Host" sap:VirtualizedContainerService.HintSize="12979,1572">
                      <Sequence.Variables>
                        <Variable x:TypeArguments="sma:PSDataCollection(sma:PSObject)" Name="SessionDirectory" />
                        <Variable x:TypeArguments="sma:PSDataCollection(sma:PSObject)" Name="IPAddresses" />
                        <Variable x:TypeArguments="s:String[]" Name="IPAddressToRedirect" />
                      </Sequence.Variables>
                      <sap:WorkflowViewStateService.ViewState>
                        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                        </scg3:Dictionary>
                      </sap:WorkflowViewStateService.ViewState>
                      <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement;&#xA;Add-RDSHServer -Name $using:server -CollectionAlias $using:CollectionAlias -ConnectionBroker $using:RDManagementServer -ManagementServer $using:RDManagementServer -ActivityId $using:RDSHProgressID" sap:VirtualizedContainerService.HintSize="12957,98" />
                      <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="12957,246">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                          </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <Assign sap:VirtualizedContainerService.HintSize="242,60">
                          <Assign.To>
                            <OutArgument x:TypeArguments="x:Int32">[CurrentProgress]</OutArgument>
                          </Assign.To>
                          <Assign.Value>
                            <InArgument x:TypeArguments="x:Int32">[CurrentProgress + (40 \ RDSHServer.Length)]</InArgument>
                          </Assign.Value>
                        </Assign>
                        <mpua:WriteProgress Activity="Add-RDSessionHost" DisplayName="Progress : Current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[RDSHProgressID]" Status="In Progress..." />
                      </Sequence>
                      <mpa:InlineScript Command="function Get-SecurityGroupMember { param ([Parameter(Mandatory=$TRUE)] [string] $GroupSID ) try { $sid = New-Object System.Security.Principal.SecurityIdentifier $GroupSID; $groupName = $sid.Translate([System.Security.Principal.NTAccount]).Value.split('\')[1]; $directoryEntry = [ADSI]('WinNT://{0}/{1},group' -f $Env:COMPUTERNAME, $groupName); foreach($member in $directoryEntry.Invoke('Members', $NULL)) { $objPath = (New-Object System.DirectoryServices.DirectoryEntry $member).Path; if ($objPath -match '^WinNT://(.*)$') { ($matches[1]) -replace '/', '\' } } } catch { throw $_ } }; function Add-SecurityGroupMember { param ( [Parameter(Mandatory=$TRUE)] [string] $GroupSID, [Parameter(Mandatory=$TRUE)] [string[]] $Member, [switch] $IsComputer ) try { $sid = New-Object System.Security.Principal.SecurityIdentifier $GroupSID; $groupName = $sid.Translate([System.Security.Principal.NTAccount]).Value.split('\')[1]; $directoryEntry = [ADSI]('WinNT://{0}/{1},group' -f $Env:COMPUTERNAME, $groupName) } catch { throw $_ };  foreach($entry in $Member) { $memberPath = 'WinNT:/'; $parts = $entry -split '\\'; foreach ($part in $parts) { $memberPath = $memberPath + '/' + $part; }; if ($IsComputer) { $memberPath = $memberPath + '$' }; $directoryEntry.Invoke('Add', $memberPath); } }; function Remove-SecurityGroupMember { param ( [Parameter(Mandatory=$TRUE)] [string] $GroupSID, [Parameter(Mandatory=$TRUE)] [string[]] $Member, [switch] $IsComputer ) try { $sid = New-Object System.Security.Principal.SecurityIdentifier $GroupSID; $groupName = $sid.Translate([System.Security.Principal.NTAccount]).Value.split('\')[1]; $directoryEntry = [ADSI]('WinNT://{0}/{1},group' -f $Env:COMPUTERNAME, $groupName) } catch { throw $_ };  foreach($entry in $Member) {  $memberPath = 'WinNT:/'; $parts = $entry -split '\\'; foreach ($part in $parts) { $memberPath = $memberPath + '/' + $part; }; if ($IsComputer) { $memberPath = $memberPath + '$' }; $directoryEntry.Invoke('Remove', $memberPath); } }; function Set-SecurityGroupMember { param ( [Parameter(Mandatory=$TRUE)] [string] $GroupSID, [Parameter(Mandatory=$TRUE)] [string[]] $Member, [switch] $IsComputer ) Get-SecurityGroupMember $GroupSID | %{Remove-SecurityGroupMember $GroupSID $_}; Add-SecurityGroupMember $GroupSID $Member -IsComputer:$IsComputer }; Set-SecurityGroupMember -GroupSID 'S-1-5-32-555' -Member $using:User" DisplayName="Add User to 'Remote Desktop Users' " sap:VirtualizedContainerService.HintSize="12957,96" PSComputerName="[{server}]" PSError="[LoopErrors2]" Result="[Null]" />
                      <If Condition="[LoopErrors2.Count &lt;&gt; 0]" DisplayName="Write RDMS Error" sap:VirtualizedContainerService.HintSize="12957,602">
                        <If.Then>
                          <Sequence sap:VirtualizedContainerService.HintSize="264,246">
                            <Assign sap:VirtualizedContainerService.HintSize="242,60">
                              <Assign.To>
                                <OutArgument x:TypeArguments="sma:ErrorRecord">[catchErrorRecord]</OutArgument>
                              </Assign.To>
                              <Assign.Value>
                                <InArgument x:TypeArguments="sma:ErrorRecord">[ErrorUtility.GetErrorRecord(RDManagementResources.ResourceManager.GetString("FailedToSetSessionHostObjects"), server, 2, LoopErrors2(0).Exception)]</InArgument>
                              </Assign.Value>
                            </Assign>
                            <mpua:WriteError DisplayName="Write-Error" ErrorRecord="[catchErrorRecord]" sap:VirtualizedContainerService.HintSize="242,22" />
                          </Sequence>
                        </If.Then>
                        <If.Else>
                          <Sequence DisplayName="Write Status Object" sap:VirtualizedContainerService.HintSize="240,494">
                            <Sequence.Variables>
                              <Variable x:TypeArguments="sma:PSObject" Default="[New PSObject()]" Name="StatusObject" />
                            </Sequence.Variables>
                            <sap:WorkflowViewStateService.ViewState>
                              <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                              </scg3:Dictionary>
                            </sap:WorkflowViewStateService.ViewState>
                            <InvokeMethod sap:VirtualizedContainerService.HintSize="218,134" MethodName="Add">
                              <InvokeMethod.TargetObject>
                                <InArgument x:TypeArguments="sma:PSMemberInfoCollection(sma:PSPropertyInfo)">[StatusObject.Properties]</InArgument>
                              </InvokeMethod.TargetObject>
                              <InArgument x:TypeArguments="sma:PSNoteProperty">[New PSNoteProperty("ServerName", server)]</InArgument>
                            </InvokeMethod>
                            <InvokeMethod sap:VirtualizedContainerService.HintSize="218,134" MethodName="Add">
                              <InvokeMethod.TargetObject>
                                <InArgument x:TypeArguments="sma:PSMemberInfoCollection(sma:PSPropertyInfo)">[StatusObject.Properties]</InArgument>
                              </InvokeMethod.TargetObject>
                              <InArgument x:TypeArguments="sma:PSNoteProperty">[New PSNoteProperty("Success", True)]</InArgument>
                            </InvokeMethod>
                            <mpua:WriteOutput DisplayName="Write-Output" sap:VirtualizedContainerService.HintSize="218,22" InputObject="[{StatusObject}]" />
                          </Sequence>
                        </If.Else>
                      </If>
                      <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="12957,246">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                          </scg3:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <Assign sap:VirtualizedContainerService.HintSize="242,60">
                          <Assign.To>
                            <OutArgument x:TypeArguments="x:Int32">[CurrentProgress]</OutArgument>
                          </Assign.To>
                          <Assign.Value>
                            <InArgument x:TypeArguments="x:Int32">[CurrentProgress + (40 \ RDSHServer.Length)]</InArgument>
                          </Assign.Value>
                        </Assign>
                        <mpua:WriteProgress Activity="Add-RDSessionHost" DisplayName="Progress : Current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[RDSHProgressID]" Status="In Progress..." />
                      </Sequence>
                    </Sequence>
                  </If.Else>
                </If>
              </Sequence>
            </TryCatch.Try>
            <TryCatch.Catches>
              <Catch x:TypeArguments="s:Exception" sap:VirtualizedContainerService.HintSize="4878,21">
                <sap:WorkflowViewStateService.ViewState>
                  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
                  </scg3:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
                <ActivityAction x:TypeArguments="s:Exception">
                  <ActivityAction.Argument>
                    <DelegateInArgument x:TypeArguments="s:Exception" Name="exception" />
                  </ActivityAction.Argument>
                  <Sequence sap:VirtualizedContainerService.HintSize="264,246">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                      </scg3:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <Assign sap:VirtualizedContainerService.HintSize="242,60">
                      <Assign.To>
                        <OutArgument x:TypeArguments="sma:ErrorRecord">[catchErrorRecord]</OutArgument>
                      </Assign.To>
                      <Assign.Value>
                        <InArgument x:TypeArguments="sma:ErrorRecord">[ErrorUtility.GetErrorRecord(RDManagementResources.ResourceManager.GetString("FailedToSetSessionHostObjects"), server, ErrorId.ConfigureRDSessionHost, 2, exception)]</InArgument>
                      </Assign.Value>
                    </Assign>
                    <mpua:WriteError DisplayName="Write-Error" ErrorRecord="[catchErrorRecord]" sap:VirtualizedContainerService.HintSize="242,22" />
                  </Sequence>
                </ActivityAction>
              </Catch>
            </TryCatch.Catches>
          </TryCatch>
        </Sequence>
      </ActivityAction>
    </ForEach>
    <mpua:WriteProgress Activity="New-RDSHCollection" Completed="[True]" DisplayName="Progress : 100" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="100" ProgressId="[RDSHProgressID]" Status="In Progress..." />
    <If Condition="[true = EnableUserDisk]" sap:VirtualizedContainerService.HintSize="4944,51">
      <sap:WorkflowViewStateService.ViewState>
        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">False</x:Boolean>
          <x:Boolean x:Key="IsPinned">False</x:Boolean>
        </scg3:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <If.Then>
        <Sequence sap:VirtualizedContainerService.HintSize="1410,616">
          <sap:WorkflowViewStateService.ViewState>
            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
              <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            </scg3:Dictionary>
          </sap:WorkflowViewStateService.ViewState>
          <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement\Enable-RDSHUserDataVHD.Xaml;&#xA;Enable-RDSHUserDataVHD -CollectionAlias $using:CollectionAlias -RemapMode $using:RemapMode -DiskType $using:DiskType -DiskSize $using:DiskSize -RDMSServer $using:RDManagementServer -UserVhdShare $using:UserVHDShare -ApplyOnServers $true" sap:VirtualizedContainerService.HintSize="1388,98" PSError="[errors]" PSRequiredModules="[{&quot;PSWorkflow&quot;}]" />
          <If Condition="[errors.Count &lt;&gt; 0]" DisplayName="Quit If Error" sap:VirtualizedContainerService.HintSize="1388,354">
            <If.Then>
              <Sequence sap:VirtualizedContainerService.HintSize="264,246">
                <Assign sap:VirtualizedContainerService.HintSize="242,60">
                  <Assign.To>
                    <OutArgument x:TypeArguments="sma:ErrorRecord">[catchErrorRecord]</OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="sma:ErrorRecord">[ErrorUtility.GetErrorRecord(string.Format(RDManagementResources.ResourceManager.GetString("FailedToEnableUserStateVHD"), "UserVHDShare"), string.Empty, ErrorId.CreateSessionCollection, 1, errors(0).Exception)]</InArgument>
                  </Assign.Value>
                </Assign>
                <mpua:WriteError DisplayName="Write-Error" ErrorRecord="[catchErrorRecord]" sap:VirtualizedContainerService.HintSize="242,22" />
              </Sequence>
            </If.Then>
          </If>
        </Sequence>
      </If.Then>
    </If>
    <mpua:WriteProgress Activity="New-RDSHCollection" Completed="[True]" DisplayName="Progress : 100" sap:VirtualizedContainerService.HintSize="4944,22" PercentComplete="100" ProgressId="[CBProgressID]" Status="In Progress..." />
    <mpua:WriteVerbose DisplayName="Verbose: Done!" sap:VirtualizedContainerService.HintSize="4944,22" Message="Done!" />
  </Sequence>
</Activity>