﻿<Activity mc:Ignorable="sads sap" x:Class="PostInstallConfiguration.Remove_HostServers" this:Remove_HostServers.RDHostServers="[{&quot;&quot;}]" this:Remove_HostServers.RoleFeatureName="RDS-Virtualization"
 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: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.Core"
 xmlns:s2="clr-namespace:System;assembly=System"
 xmlns:s3="clr-namespace:System;assembly=System.ServiceModel"
 xmlns:s4="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.Core"
 xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System"
 xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
 xmlns:sm="clr-namespace:System.Management;assembly=System.Management"
 xmlns:sma="clr-namespace:System.Management.Automation;assembly=System.Management.Automation"
 xmlns:this="clr-namespace:PostInstallConfiguration"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="RDMSServer" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="Results" Type="OutArgument(sma:PSDataCollection(sma:PSObject))" />
    <x:Property Name="RDHostServers" Type="InArgument(s:String[])">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
    <x:Property Name="RoleFeatureName" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
  </x:Members>
  <this:Remove_HostServers.RDMSServer>
    <InArgument x:TypeArguments="x:String">
      <Literal x:TypeArguments="x:String" Value="" />
    </InArgument>
  </this:Remove_HostServers.RDMSServer>
  <sap:VirtualizedContainerService.HintSize>1141,5703</sap:VirtualizedContainerService.HintSize>
  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
  <sap:WorkflowViewStateService.ViewState>
    <scg2:Dictionary x:TypeArguments="x:String, x:Object">
      <x:Boolean x:Key="ShouldCollapseAll">True</x:Boolean>
      <x:Boolean x:Key="ShouldExpandAll">False</x:Boolean>
    </scg2:Dictionary>
  </sap:WorkflowViewStateService.ViewState>
  <Sequence sap:VirtualizedContainerService.HintSize="1101,5663">
    <Sequence.Variables>
      <Variable x:TypeArguments="x:String" Name="RDMSServersGroup">
        <Variable.Default>
          <Literal x:TypeArguments="x:String" Value="" />
        </Variable.Default>
      </Variable>
      <Variable x:TypeArguments="x:String" Name="SessionBrokerComputersGroup">
        <Variable.Default>
          <Literal x:TypeArguments="x:String" Value="" />
        </Variable.Default>
      </Variable>
      <Variable x:TypeArguments="x:String" Name="ShortRDMSServerName">
        <Variable.Default>
          <Literal x:TypeArguments="x:String" Value="" />
        </Variable.Default>
      </Variable>
      <Variable x:TypeArguments="x:String" Name="RDMSServerDomain">
        <Variable.Default>
          <Literal x:TypeArguments="x:String" Value="" />
        </Variable.Default>
      </Variable>
      <Variable x:TypeArguments="x:String" Default="S-1-5-32-577" Name="RDMSServersGroupSID" />
      <Variable x:TypeArguments="x:String" Default="S-1-5-32-576" Name="SessionBrokerComputersGroupSID" />
      <Variable x:TypeArguments="x:Boolean" Default="True" Name="IsRDVH" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg2:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg2:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <Sequence DisplayName="InputValidation" sap:VirtualizedContainerService.HintSize="1079,51">
      <sap:WorkflowViewStateService.ViewState>
        <scg2:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">False</x:Boolean>
          <x:Boolean x:Key="IsPinned">False</x:Boolean>
        </scg2:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <If Condition="[RDMSServer.Length = 0 Or (Not RDMSServer.Contains(&quot;.&quot;))]" sap:VirtualizedContainerService.HintSize="711,540">
        <sap:WorkflowViewStateService.ViewState>
          <scg2:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">True</x:Boolean>
          </scg2:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <If.Then>
          <TerminateWorkflow Exception="[New System.ArgumentException(&quot;Invalid Input&quot;)]" sap:VirtualizedContainerService.HintSize="200,22" Reason="[RDManagementResources.InvalidFqdnManagementServer]" />
        </If.Then>
        <If.Else>
          <Sequence sap:VirtualizedContainerService.HintSize="486,432">
            <sap:WorkflowViewStateService.ViewState>
              <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                <x:Boolean x:Key="IsPinned">True</x:Boolean>
              </scg2:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <Assign sap:VirtualizedContainerService.HintSize="464,60">
              <Assign.To>
                <OutArgument x:TypeArguments="x:String">[RDMSServerDomain]</OutArgument>
              </Assign.To>
              <Assign.Value>
                <InArgument x:TypeArguments="x:String">[Microsoft.RemoteDesktopServices.Common.CommonUtility.GetDomainNameFromLiveComputer(RDMSServer)]</InArgument>
              </Assign.Value>
            </Assign>
            <If Condition="[RDMSServerDomain.Length = 0]" sap:VirtualizedContainerService.HintSize="464,208">
              <sap:WorkflowViewStateService.ViewState>
                <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                  <x:Boolean x:Key="IsPinned">True</x:Boolean>
                  <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                </scg2:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
              <If.Then>
                <TerminateWorkflow Exception="[New System.ArgumentException(&quot;Invalid Input&quot;)]" sap:VirtualizedContainerService.HintSize="200,22" Reason="[RDManagementResources.InvalidFqdnManagementServer]" />
              </If.Then>
            </If>
          </Sequence>
        </If.Else>
      </If>
      <If Condition="[RDHostServers.Length &gt; 0]" sap:VirtualizedContainerService.HintSize="711,51">
        <sap:WorkflowViewStateService.ViewState>
          <scg2:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
            <x:Boolean x:Key="IsExpanded">False</x:Boolean>
          </scg2:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <If.Then>
          <Sequence sap:VirtualizedContainerService.HintSize="785,896">
            <sap:WorkflowViewStateService.ViewState>
              <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                <x:Boolean x:Key="IsPinned">True</x:Boolean>
              </scg2:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <ForEach x:TypeArguments="x:String" DisplayName="ForEach&lt;String&gt;" sap:VirtualizedContainerService.HintSize="763,772" Values="[RDHostServers]">
              <sap:WorkflowViewStateService.ViewState>
                <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                  <x:Boolean x:Key="IsPinned">True</x:Boolean>
                </scg2:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
              <ActivityAction x:TypeArguments="x:String">
                <ActivityAction.Argument>
                  <DelegateInArgument x:TypeArguments="x:String" Name="Server" />
                </ActivityAction.Argument>
                <Sequence sap:VirtualizedContainerService.HintSize="733,664">
                  <sap:WorkflowViewStateService.ViewState>
                    <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                      <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                      <x:Boolean x:Key="IsPinned">True</x:Boolean>
                    </scg2:Dictionary>
                  </sap:WorkflowViewStateService.ViewState>
                  <If Condition="[Server.Length = 0 Or (Not Server.Contains(&quot;.&quot;))]" sap:VirtualizedContainerService.HintSize="711,540">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                        <x:Boolean x:Key="IsPinned">True</x:Boolean>
                      </scg2:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <If.Then>
                      <TerminateWorkflow Exception="[New System.ArgumentException(&quot;Invalid Input&quot;)]" sap:VirtualizedContainerService.HintSize="200,22" Reason="[RDManagementResources.InvalidFqdnVirtualizationHost]" />
                    </If.Then>
                    <If.Else>
                      <Sequence sap:VirtualizedContainerService.HintSize="486,432">
                        <Sequence.Variables>
                          <Variable x:TypeArguments="x:String" Name="RDVHServerdomain">
                            <Variable.Default>
                              <Literal x:TypeArguments="x:String" Value="" />
                            </Variable.Default>
                          </Variable>
                        </Sequence.Variables>
                        <sap:WorkflowViewStateService.ViewState>
                          <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                            <x:Boolean x:Key="IsPinned">True</x:Boolean>
                          </scg2:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <Assign sap:VirtualizedContainerService.HintSize="464,60">
                          <Assign.To>
                            <OutArgument x:TypeArguments="x:String">[RDVHServerdomain]</OutArgument>
                          </Assign.To>
                          <Assign.Value>
                            <InArgument x:TypeArguments="x:String">[Microsoft.RemoteDesktopServices.Common.CommonUtility.GetDomainNameFromJoinedNode(RDMSServer, Server)]</InArgument>
                          </Assign.Value>
                        </Assign>
                        <If Condition="[RDVHServerdomain.Length = 0]" sap:VirtualizedContainerService.HintSize="464,208">
                          <sap:WorkflowViewStateService.ViewState>
                            <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                              <x:Boolean x:Key="IsPinned">True</x:Boolean>
                              <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                            </scg2:Dictionary>
                          </sap:WorkflowViewStateService.ViewState>
                          <If.Then>
                            <TerminateWorkflow Exception="[New System.ArgumentException(&quot;Invalid Input&quot;)]" sap:VirtualizedContainerService.HintSize="200,22" Reason="[RDManagementResources.InvalidFqdnVirtualizationHost]" />
                          </If.Then>
                        </If>
                      </Sequence>
                    </If.Else>
                  </If>
                </Sequence>
              </ActivityAction>
            </ForEach>
          </Sequence>
        </If.Then>
      </If>
    </Sequence>
    <Sequence DisplayName="Initialization" sap:VirtualizedContainerService.HintSize="1079,51">
      <sap:WorkflowViewStateService.ViewState>
        <scg2:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">False</x:Boolean>
          <x:Boolean x:Key="IsPinned">False</x:Boolean>
        </scg2:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <Assign sap:VirtualizedContainerService.HintSize="242,60">
        <Assign.To>
          <OutArgument x:TypeArguments="sma:PSDataCollection(sma:PSObject)">[Results]</OutArgument>
        </Assign.To>
        <Assign.Value>
          <InArgument x:TypeArguments="sma:PSDataCollection(sma:PSObject)">[New PSDataCollection(Of PSObject)]</InArgument>
        </Assign.Value>
      </Assign>
    </Sequence>
    <Sequence DisplayName="Removing RDH Servers" sap:VirtualizedContainerService.HintSize="1079,5357">
      <Sequence.Variables>
        <Variable x:TypeArguments="x:Boolean" Default="True" Name="IsSuccess" />
        <Variable x:TypeArguments="x:String" Name="ServerDomainName">
          <Variable.Default>
            <Literal x:TypeArguments="x:String" Value="" />
          </Variable.Default>
        </Variable>
        <Variable x:TypeArguments="sc:Hashtable" Default="[new Hashtable()]" Name="setWMIParams" />
      </Sequence.Variables>
      <sap:WorkflowViewStateService.ViewState>
        <scg2:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          <x:Boolean x:Key="IsPinned">True</x:Boolean>
        </scg2:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <ForEach x:TypeArguments="x:String" DisplayName="ForEach&lt;String&gt;" sap:VirtualizedContainerService.HintSize="1057,5233" Values="[RDHostServers]">
        <sap:WorkflowViewStateService.ViewState>
          <scg2:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsPinned">True</x:Boolean>
          </scg2:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <ActivityAction x:TypeArguments="x:String">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="x:String" Name="ServerName" />
          </ActivityAction.Argument>
          <Sequence sap:VirtualizedContainerService.HintSize="1027,5125">
            <Sequence.Variables>
              <Variable x:TypeArguments="x:Boolean" Default="False" Name="RemoveJoinedServer" />
            </Sequence.Variables>
            <sap:WorkflowViewStateService.ViewState>
              <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                <x:Boolean x:Key="IsPinned">True</x:Boolean>
              </scg2:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <Sequence DisplayName="Common Configuration" sap:VirtualizedContainerService.HintSize="1005,51">
              <sap:WorkflowViewStateService.ViewState>
                <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                  <x:Boolean x:Key="IsExpanded">False</x:Boolean>
                  <x:Boolean x:Key="IsPinned">False</x:Boolean>
                </scg2:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
              <mpa:InlineScript Command="import-module $env:windir\System32\ServerManagerInternal\rdmanagement;&#xD;&#xA;Remove-RDMSJoinedNode -ManagementServer $using:RDMSServer -MachineName $using:ServerName -RoleName $using:RoleFeatureName" sap:VirtualizedContainerService.HintSize="858,139" Result="[Results]">
                <sap:WorkflowViewStateService.ViewState>
                  <scg2:Dictionary x:TypeArguments="x:String, x:Object">
                    <x:Boolean x:Key="IsPinned">True</x:Boolean>
                    <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                  </scg2:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
              </mpa:InlineScript>
            </Sequence>
          </Sequence>
        </ActivityAction>
      </ForEach>
    </Sequence>
  </Sequence>
</Activity>
