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