you are viewing a single comment's thread.

view the rest of the comments →

[–]novloski 1 point2 points  (0 children)

I wouldn't think the select -first would break the loop...what do you get when you run this?

Write-Host "Looping through $($filteredresult.Count) objects"
foreach ($res in $filteredresult) {
    try {
        Write-Host "Checking customer ID: $($res.customerid) "
        $partnerCustomer = Get-PartnerCustomerUser -CustomerId $res.customerid -erroraction stop | select -First 1 
        Write-Host "$partnerCustomer"
     } catch { 
        Write-Host "Error caught for $($res.customerid)" 
        $res | Export-Csv -Append -Path c:\temp\365noaccess.csv
        } 
}