<Activity mc:Ignorable="sads sap" x:Class="RDManagement.Remove_RDSessionHost"
 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:mpua="clr-namespace:Microsoft.PowerShell.Utility.Activities;assembly=Microsoft.PowerShell.Utility.Activities"
 xmlns:mrma="clr-namespace:Microsoft.RemoteDesktopServices.Management.Activities;assembly=Microsoft.RemoteDesktopServices.Management.Activities"
 xmlns:mrc="clr-namespace:Microsoft.RemoteDesktopServices.Common;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: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: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:sma="clr-namespace:System.Management.Automation;assembly=System.Management.Automation"
 xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
 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="RDSHServer" Type="InArgument(s:String[])">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
  </x:Members>
  <sap:VirtualizedContainerService.HintSize>440,503</sap:VirtualizedContainerService.HintSize>
  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
  <Sequence DisplayName="Remove RDSH from a collection" sap:VirtualizedContainerService.HintSize="222,423">
    <Sequence.Variables>
      <Variable x:TypeArguments="sma:PSDataCollection(sma:PSObject)" Name="Output" />
      <Variable x:TypeArguments="x:Int32" Default="1" Modifiers="ReadOnly" Name="ProgressID" />
      <Variable x:TypeArguments="x:Int32" Default="10" Name="CurrentProgress" />
      <Variable x:TypeArguments="sma:ErrorRecord" Name="catchErrorRecord" />
    </Sequence.Variables>
    <mpua:WriteProgress Completed="{x:Null}" CurrentOperation="{x:Null}" ParentId="{x:Null}" SecondsRemaining="{x:Null}" SourceId="{x:Null}" Activity="Remove-RDSessionHost" DisplayName="Progress : 0" sap:VirtualizedContainerService.HintSize="200,22" PercentComplete="0" ProgressId="[ProgressID]" Status="In Progress..." />
    <mpua:WriteVerbose DisplayName="Verbose: Input" sap:VirtualizedContainerService.HintSize="200,22" Message="[&quot;Management Server: &quot; + RDManagementServer + Environment.NewLine +&#xA;&quot;RDSHServer: &quot; + String.Join(&quot;, &quot;, RDSHServer)]" />
    <mpua:WriteProgress Completed="{x:Null}" CurrentOperation="{x:Null}" ParentId="{x:Null}" SecondsRemaining="{x:Null}" SourceId="{x:Null}" Activity="Remove-RDSessionHost" DisplayName="Progress : 10" sap:VirtualizedContainerService.HintSize="200,22" PercentComplete="10" ProgressId="[ProgressID]" Status="In Progress..." />
    <ParallelForEach x:TypeArguments="x:String" DisplayName="Remove RDSH servers" sap:VirtualizedContainerService.HintSize="200,51" Values="[RDSHServer]">
      <ActivityAction x:TypeArguments="x:String">
        <ActivityAction.Argument>
          <DelegateInArgument x:TypeArguments="x:String" Name="server" />
        </ActivityAction.Argument>
        <Sequence DisplayName="Configure RDSH server" sap:VirtualizedContainerService.HintSize="602,1918">
              <Sequence.Variables>
                <Variable x:TypeArguments="sma:PSDataCollection(sma:ErrorRecord)" Default="[New PSDataCollection(Of ErrorRecord)()]" Name="LoopErrors" />
              </Sequence.Variables>
          <TryCatch sap:VirtualizedContainerService.HintSize="504,807">
            <TryCatch.Try>
              <Sequence sap:VirtualizedContainerService.HintSize="486,580">
          <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement;&#xD;&#xA;Remove-RDSHServer -Name $using:server -ManagementServer $using:RDManagementServer" sap:VirtualizedContainerService.HintSize="580,188" PSError="[LoopErrors]" />
          <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="580,246">
            <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 + (45 \ RDSHServer.Length)]</InArgument>
              </Assign.Value>
            </Assign>
            <mpua:WriteProgress Completed="{x:Null}" CurrentOperation="{x:Null}" ParentId="{x:Null}" SecondsRemaining="{x:Null}" SourceId="{x:Null}" Activity="Remove-RDSessionHost" DisplayName="Progress : current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[ProgressID]" Status="In Progress..." />
          </Sequence>
            <If Condition="[LoopErrors.Count &lt;&gt; 0]" DisplayName="Write RDMS Error" sap:VirtualizedContainerService.HintSize="558,642">
              <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, ErrorId.ConfigureRDSessionHost, LoopErrors(0).Exception)]</InArgument>
                    </Assign.Value>
                  </Assign>
                  <mpua:WriteError 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>
                  <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 sap:VirtualizedContainerService.HintSize="218,22" InputObject="[{StatusObject}]" />
                </Sequence>
              </If.Else>
            </If>
          <Sequence DisplayName="Update Progress" sap:VirtualizedContainerService.HintSize="580,246">
            <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 + (45 \ RDSHServer.Length)]</InArgument>
              </Assign.Value>
            </Assign>
            <mpua:WriteProgress Completed="{x:Null}" CurrentOperation="{x:Null}" ParentId="{x:Null}" SecondsRemaining="{x:Null}" SourceId="{x:Null}" Activity="Remove-RDSessionHost" DisplayName="Progress : current" sap:VirtualizedContainerService.HintSize="242,22" PercentComplete="[CurrentProgress]" ProgressId="[ProgressID]" Status="In Progress..." />
          </Sequence>
              </Sequence>
            </TryCatch.Try>
            <TryCatch.Catches>
              <Catch x:TypeArguments="s:Exception" sap:VirtualizedContainerService.HintSize="490,21">
                <ActivityAction x:TypeArguments="s:Exception">
                  <ActivityAction.Argument>
                    <DelegateInArgument x:TypeArguments="s:Exception" Name="exception" />
                  </ActivityAction.Argument>
                  <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, ErrorId.ConfigureRDSessionHost, exception)]</InArgument>
                      </Assign.Value>
                    </Assign>
                    <mpua:WriteError ErrorRecord="[catchErrorRecord]" sap:VirtualizedContainerService.HintSize="242,22" />
                  </Sequence>
                </ActivityAction>
              </Catch>
            </TryCatch.Catches>
          </TryCatch>
        </Sequence>
      </ActivityAction>
    </ParallelForEach>
    <mpua:WriteProgress CurrentOperation="{x:Null}" ParentId="{x:Null}" SecondsRemaining="{x:Null}" SourceId="{x:Null}" Activity="Remove-RDSessionHost" Completed="[True]" DisplayName="Progress : 100" sap:VirtualizedContainerService.HintSize="200,22" PercentComplete="100" ProgressId="[ProgressID]" Status="In Progress..." />
  </Sequence>
</Activity>
