How to connect to ARS v8 from PowerShell?

I have the following function in PowerShell:

Function Get-ARSServers {

$searchRoot = "CN=Enterprise Directory Manager,CN=Aelita,CN=System,$([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry() | Select-Object -ExpandProperty DistinguishedName)"


Get-QADObject -SearchRoot $searchRoot -Type serviceConnectionPoint | SELECT-object -ExpandProperty Name | Where-object { $_.indexOf(":17228") -gt 0 } | Select-object @{name='serverName';expression={$_.split(":")[0]}} | select-object -ExpandProperty serverName

}

This is then called via this code:

$QARSServerFQDN = Get-ARSServers | Select-Object -First 1
Connect-QADService -Service $QARSServerFQDN -Proxy

However, I get an error and I'm not sure why:

Get-QADObject : The pipeline has been stopped.
At C:\ARS Scripts\lzcreation.ps1:267 char:5
+ Get-QADObject -SearchRoot $searchRoot -Type serviceConnectionPo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-QADObject], PipelineStoppedException
+ FullyQualifiedErrorId : ActiveRoles.ManagementShell.Powershell.Cmdlets.GetGenericObjectCmdlet

Parents
  • For anyone who may need this in the future, the correct code looks like this:

    Function Get-ARSServers {

    $searchRoot = "CN=Enterprise Directory Manager,CN=Aelita,CN=System,$([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry() | Select-Object -ExpandProperty DistinguishedName)"
    Get-QADObject -SearchRoot $searchRoot -Type serviceConnectionPoint | SELECT-object -ExpandProperty Name | Where-object { $_.indexOf(":17228") -gt 0 } | Select-object @{name='serverName';expression={$_.split(":")[0]}} | select-object -ExpandProperty serverName

    }


    #Get the currently active ARS server
    $QARSServerFQDN = (Get-ARSServers) | select-object -First 1
    #Connect to Active Roles Server
    Connect-QADService -Service $QARSServerFQDN -Proxy

  • Two things:

    1) The Active Roles Administration Service FQDN is stored separately on the serviceBindingInformation attribute of the Service Connection Point, so you just need to get that value instead of all of the string manipulation on the name:

    Function Get-ARSServers {

    $searchRoot = "CN=Enterprise Directory Manager,CN=Aelita,CN=System,$([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry() | Select-Object -ExpandProperty DistinguishedName)"


    (Get-QADObject -SearchRoot $searchRoot -Type serviceConnectionPoint -IncludedProperties serviceBindingInformation | SELECT-object serviceBindingInformation).serviceBindingInformation

    }

    #Get the currently active ARS server
    $QARSServerFQDN = (Get-ARSServers) | select-object -First 1
    #Connect to Active Roles Server
    Connect-QADService -Service $QARSServerFQDN -Proxy

    2) This functionality is built into the Connect-QADService cmdlet. If you just use -Proxy without specifying -Service, then the service connection points will be read and the first one will be connected to:

    Connect-QADService -Proxy

Reply
  • Two things:

    1) The Active Roles Administration Service FQDN is stored separately on the serviceBindingInformation attribute of the Service Connection Point, so you just need to get that value instead of all of the string manipulation on the name:

    Function Get-ARSServers {

    $searchRoot = "CN=Enterprise Directory Manager,CN=Aelita,CN=System,$([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry() | Select-Object -ExpandProperty DistinguishedName)"


    (Get-QADObject -SearchRoot $searchRoot -Type serviceConnectionPoint -IncludedProperties serviceBindingInformation | SELECT-object serviceBindingInformation).serviceBindingInformation

    }

    #Get the currently active ARS server
    $QARSServerFQDN = (Get-ARSServers) | select-object -First 1
    #Connect to Active Roles Server
    Connect-QADService -Service $QARSServerFQDN -Proxy

    2) This functionality is built into the Connect-QADService cmdlet. If you just use -Proxy without specifying -Service, then the service connection points will be read and the first one will be connected to:

    Connect-QADService -Proxy

Children
No Data