Please send (off list if you prefer) a complete "Get-OutlookProvider | 
format-list *".

Save the attached file as Get-ServiceConnectionPoint.ps1, run in an elevated 
PowerShell session:

               .\Get-ServiceConnectionPoint.ps1 -Verbose

Please send me all the output, including the verbose output.

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Maglinger, Paul
Sent: Saturday, August 12, 2017 12:19 PM
To: 'exchange@lists.myitforum.com'
Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect

When I use aka.ms/exrca it comes back with this in the results:

<Type>EXPR</Type>
<Server>telstar.scvl.com</Server>
<ASUrl>https://telstarcaa.scvl.com/EWS/Exchange.asmx</ASUrl<https://telstarcaa.scvl.com/EWS/Exchange.asmx%3c/ASUrl>>
<OOFUrl>https://telstarcaa.scvl.com/EWS/Exchange.asmx</OOFUrl<https://telstarcaa.scvl.com/EWS/Exchange.asmx%3c/OOFUrl>>
<OABUrl>https://telstarcaa.scvl.com/OAB/a49ee13a-fc45-432e-9bfc-5ba79242dd72/</OABUrl<https://telstarcaa.scvl.com/OAB/a49ee13a-fc45-432e-9bfc-5ba79242dd72/%3c/OABUrl>>
<UMUrl>https://telstarcaa.scvl.com/EWS/UM2007Legacy.asmx</UMUrl<https://telstarcaa.scvl.com/EWS/UM2007Legacy.asmx%3c/UMUrl>>
<Port>0</Port>
<DirectoryPort>0</DirectoryPort>
<ReferralPort>0</ReferralPort>
<SSL>On</SSL>
<AuthPackage>Basic</AuthPackage>
<CertPrincipalName>msstd:telstarcaa.scvl.com</CertPrincipalName>
<EwsUrl>https://telstarcaa.scvl.com/EWS/Exchange.asmx</EwsUrl<https://telstarcaa.scvl.com/EWS/Exchange.asmx%3c/EwsUrl>>
<EcpUrl>https://telstarcaa.scvl.com/ecp/</EcpUrl<https://telstarcaa.scvl.com/ecp/%3c/EcpUrl>>
<EcpUrl-um>?p=customize/voicemail.aspx&amp;exsvurl=1</EcpUrl-um>
<EcpUrl-aggr>?p=personalsettings/EmailSubscriptions.slab&amp;exsvurl=1</EcpUrl-aggr>
<EcpUrl-mt>PersonalSettings/DeliveryReport.aspx?exsvurl=1&amp;IsOWA=&lt;IsOWA&gt;&amp;MsgID=&lt;MsgID&gt;&amp;Mbx=&lt;Mbx&gt;</EcpUrl-mt>
<EcpUrl-ret>?p=organize/retentionpolicytags.slab&amp;exsvurl=1</EcpUrl-ret>
<EcpUrl-sms>?p=sms/textmessaging.slab&amp;exsvurl=1</EcpUrl-sms>
</Protocol>
<Protocol>

And the entry for the <server> is incorrect.  However when I run

#Get-OutlookProvider -Identity EXPR | fl

that section is blank.

I found something that said if it wasn't blank to run

#Set-OutlookProvider -id EXPR -server $null

I'm not sure if running it would fix it or not.  Also not sure it should be 
null.


From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith
Sent: Friday, August 11, 2017 4:55 PM
To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>
Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect

Does it happen with aka.ms/exrca ?

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul
Sent: Friday, August 11, 2017 4:15 PM
To: 'exchange@lists.myitforum.com'
Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect


Okay, that made a difference.  It's showing all 10 servers and not the 2 ghost 
servers.  I'm still seeing the old server when I test e-mail autoconfiguration. 
 See screenshot.



[cid:image001.png@01D3145E.1968DB60]



Paul



-----Original Message-----
From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith
Sent: Thursday, August 10, 2017 7:57 PM
To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>
Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Duh



My bad. Yes, specify -allServers



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Thursday, August 10, 2017 4:55 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



I'm looking over your script and see at the top where if I wanted to see all 
servers that I should add an allServers parameter.

This parameter appears to be there as



[Parameter( Mandatory = $false )]

[switch] $allServers = $false



Do I need to make a change in the script?  What's odd is that it pulled down 
all the servers the very first time I ran it - now it just pulls down the 
server it runs on.





-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Thursday, August 10, 2017 11:13 AM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Curiouser and curiouser.



Then I have no explanation. I'm sorry.



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Thursday, August 10, 2017 12:04 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Nice.  All DCs came back with all of the existing Exchange servers and none of 
the "ghosts".





-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Thursday, August 10, 2017 10:42 AM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



IsValid means that the object passes AD validation. Whenever you assign a value 
to an object attribute in AD it goes through a validation routine based on the 
OID of the attribute type. IsValid means that all attribute values pass those 
validation routines on an object.



To answer your specific question: no.



But there is a potentially interesting experiment to try.



Let's assume you have a list, $dcs, of the fqdn's of your domain controllers.



$dcs = 'dc1.scvl.com', 'dc2.scvl.com', 'dc3.scvl.com'



foreach( $dc in $dcs )

{

                "*** $dc ***"

                Get-ExchangeServer -Status -DomainController $dc }



Does the output change based on the DC specified?



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Thursday, August 10, 2017 11:07 AM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



I tried the script on one of the mailbox servers and it only came back with the 
server I ran it on.  For some reason when I ran your script the first time it 
came back with everything.  Since that it's only coming back with the server I 
run the script on.  And again, when I run Get-ExchangeServer on the EMS it 
comes back with all the CAS/HUB and mailbox servers and not the 2 I saw on the 
first run.



I'm intrigued by that first listing showing the decommissioned servers where 
IsValid was marked as True.  Does that give a clue where these 2 servers are 
hiding?



Paul



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Wednesday, August 09, 2017 5:10 PM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



That begins to sound like AD DS weirdness.



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Wednesday, August 9, 2017 5:56 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Okay, this is weird.  When I ran the script the first time there were 12 
servers listed under the ExchangeServer header - including 2 that were 
decommissioned.

Now when I run it there is only one - and it's the one I ran the script from 
and should be there but I don't see the other 9.





-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Wednesday, August 09, 2017 4:31 PM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



That doesn't make any sense. That's exactly what the script does:



                                $parameters = @{

                                                'Status' = $true

                                }



                                if( -not $allServers )

                                {

                                                $parameters += @{ 'Identity' = 
$env:ComputerName }

                                }



                                $r = Get-ExchangeServer @parameters



                                $r | fl Name, Identity, Fqdn, Edition,

                                                Site, OrganizationalUnit, 
ServerRole,

                                                AdminDisplayVersion, 
ExchangeVersion,

                                                Static*, Current*,

                                                Is*



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Wednesday, August 9, 2017 5:22 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



No, they do not show up.



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Wednesday, August 09, 2017 4:10 PM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Does "Get-ExchangeServer -Status" find the old servers? I bet it does...



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Wednesday, August 9, 2017 5:00 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Interesting.  When I run your script 2 decommissioned Exchange servers show up 
under the ExchangeServer header.

When I run a Get-ExchangeServer command alone they do not.

So what information are you pulling down that the Get-ExchangeServer alone 
isn't?

Additionally, everything listed under those 2 servers is either null or "False" 
except for "IsValid" which is "True"



Paul





-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Michael B. Smith

Sent: Wednesday, August 09, 2017 3:28 PM

To: exchange@lists.myitforum.com<mailto:exchange@lists.myitforum.com>

Subject: [Exchange] RE: Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Run this. (Save as ps1, run in Exchange Management Shell, the output is rather 
voluminous, so you should probably redirect to a file.)



This should tell you where the old server name is referred to.



I haven't tested this on Exchange 2010 in a while, but I think it should still 
work.



-----Original Message-----

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Maglinger, Paul

Sent: Wednesday, August 9, 2017 3:48 PM

To: 'exchange@lists.myitforum.com'

Subject: [Exchange] Test E-mail AutoConfiguration HTTP protocol server name 
incorrect



Exchange 2010 SP3 UR17

When I run Test E-mail Autoconfiguration on my workstation everything looks 
good except under the Exchange HTTP protocol heading where it has the server 
name.  The server listed was one that we decommissioned a while back.  I have 
Googled and searched for where this is coming from and I can't find it.  Can 
someone tell me where this can be changed?



TIA,



Paul



PS - Apologies if this is a multiple post - our spam filter seems to have 
acquired a dislike for the list's messages and I'm working on that.























































[CmdletBinding(SupportsShouldProcess=$false, ConfirmImpact='None') ]

Param(
        [Parameter(Mandatory=$false)]
        [string]$domain       = $null,

        [Parameter(Mandatory=$false)]
        [string]$emailDomain  = $null,

        [Parameter(Mandatory=$false)]
        [string]$emailAddress = $null
)

if( [String]::IsNullOrEmpty( $domain ) )
{
        $domain = ''
        Write-Verbose "No domain was specified"
}
if( [String]::IsNullOrEmpty( $emailDomain ) )
{
        $emailDomain = ''
        Write-Verbose "No email domain was specified"
}
if( [String]::IsNullOrEmpty( $emailAddress ) )
{
        $emailAddress = ''
        Write-Verbose "No email address was specified"
}

Set-StrictMode -Version 2.0

function IsInDomain
{
        [bool] $b = $false

        $results = gwmi Win32_ComputerSystem
        foreach( $result in $results )
        {
                $b = $result.PartOfDomain
                break
        }
        $results = $null

        return $b
}

if( $domain -eq '' -and ( IsInDomain ) )
{
        ## this can fail, if we aren't a member of a domain
        $domainObject = $null
        try
        {
                $domainObject = 
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
                $domain = $domainObject.Name
        }
        catch [ 
System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException ]
        {
                Write-Error "Cannot contact domain"
                return
        }

        $domainObject = $null
        Write-Verbose "Looked up current domain, it is $domain"
}

if( $emailDomain -eq '' -and $domain -ne '' )
{
        $emailDomain = $domain
        Write-Verbose "Email domain was empty, so it has been set to $domain"
}

## GUID for SCP URL keyword.
[string] $ScpUrlGuidString = '77378F46-2C66-4aa9-A6A6-3E7A48B19596'

## GUID for SCP pointer keyword.
[string] $ScpPtrGuidString = '67661d7F-8FC4-4fa7-BFAC-E1D7794C1F68'

## LDAP filter to search for SCP URLs and pointers
[string] $ScpFilter = "(&(objectClass=serviceConnectionPoint)" +
                       "(|(keywords=" + $ScpPtrGuidString + ")" + 
                       "(keywords=" + $ScpUrlGuidString + ")))"

function CollectionContainsExactValue
{
        Param(
                $collection, 
                [string] $value
        )

        foreach( $obj in $collection )
        {
                if( $obj -ne $null )
                {
                        $item = $obj -as [System.String]
                        if( $item -eq $value )
                        {
                                return $true
                        }
                }
        }

        return $false
}

function CollectionContainsPrefixValue
{
        Param(
                $collection, 
                [string] $value
        )

        foreach( $obj in $collection )
        {
                if( $obj -ne $Null )
                {
                        $item = $obj -as [System.String]
                        if( $item.StartsWith( $value ) )
                        {
                                return $true
                        }
                }
        }

        return $false
}

function GetScpUrls
{
        Param(
                [string] $ldapServer,
                [string] $domain
        )

        ##
        ## returns a priority ordered array of SCP URLs to try
        ##
        ## 1.Autodiscover endpoints from SCP objects scoped to the Active 
Directory 
        ##   site that the client computer belongs to
        ##
        ## 2.Autodiscover endpoints from SCP objects not scoped to any Active 
Directory site
        ##
        ## 3.Autodiscover endpoints from SCP objects scoped to a different 
Active Directory 
        ##   site than the site that the client computer belongs to
        ##

        [Array] $ScpUrlList = @()
        [string] $rootDSEpath = $null

        if( -not ( IsInDomain ) )
        {
                Write-Verbose "GetScpUrls: computer not in domain, returning 
null"
                return $null
        }

        if( [String]::IsNullOrEmpty( $ldapServer ) )
        {
                $rootDSEpath = 'LDAP://RootDSE'
        }
        else
        {
                $rootDSEpath = $ldapServer + '/RootDSE'
        }
        Write-Verbose "RootDSEpath $rootDSEpath"
        Write-Verbose "ScpFilter $ScpFilter"

        $entries = $null

        try
        {
                $rootDSE  = New-Object System.DirectoryServices.DirectoryEntry( 
$rootDSEpath )
                if($rootDSE) { write-verbose "rootdse not null" } else { 
write-verbose "rootdse is null" }
                $configNC = $rootDSE.Properties[ 'configurationNamingContext' 
].Value -as [String]
                $rootDSE  = $null

                $domainDE = New-Object System.DirectoryServices.DirectoryEntry( 
'LDAP://' + $configNC )
                $searcher = New-Object 
System.DirectoryServices.DirectorySearcher( $domainDE )
                $searcher.Filter = $ScpFilter

                $searcher.PropertiesToLoad.Add( 'keywords' ) | Out-Null
                $searcher.PropertiesToLoad.Add( 'servicebindinginformation' ) | 
Out-Null
                $searcher.PropertiesToLoad.Add( 'servicednsname' ) | Out-Null

                $entries  = $searcher.FindAll()

                $searcher = $null
                $domainDE = $null
        }
        catch
        {
                Write-Error "SCP lookup failed with $($_.ToString())"
                return $null
        }

        if( $entries -eq $null -or $entries.Count -le 0 )
        {
                $entries = $null

                Write-Verbose "No SCP records were found"
                Write-Warning "No SCP records were found"

                return $null
        }

        Write-Verbose "$($entries.Count) SCP records were found"

        [string] $fallBackLdapPath = $null

$global:entries = $entries

        ## check for SCP pointers to other domains
        foreach( $entry in $entries )
        {
                <#
                ## debug crap
                $propertyNames = $entry.Properties.PropertyNames
                foreach( $propertyName in $propertyNames )
                {
                        $property = $entry.Properties[ $propertyName ]
                        if( $property -eq $null )
                        {
                                "property $propertyName is null"
                        }
                        else
                        {
                                $count = $property.Count
                                "property $propertyName, count = $count"
                                for( $i = 0; $i -lt $count; $i++ )
                                {
                                        $element = $property.Item( $i )
                                        ".....$i - $element"
                                }
                                " "
                        }
                }
                #>

                $entryKeywords = $entry.Properties[ 'keywords' ]
                if( ( CollectionContainsExactValue $entryKeywords 
$ScpPtrGuidString ) )
                {
                        [String] $ptrLdapPath = $entry.Properties[ 
'servicebindinginformation' ][ 0 ] -as [String]

                        Write-Verbose "Keyword collection includes 
$ScpPtrGuidString"
                        Write-Verbose "ptrLdapPath $ptrLdapPath"

                        ## determine whether this pointer is scoped to the 
user's domain
                        if( ( CollectionContainsExactValue $entryKeywords ( 
'Domain=' + $domain ) ) )
                        {
                                Write-Verbose "Found SCP pointer for $domain in 
$($entry.Path)"
                                Write-Verbose "Restarting SCP lookup in 
$ptrLdapPath"

                                return ( GetScpUrls $ptrLdapPath $domain )
                        }

                        ## Save the first SCP pointer that is not scoped to a 
domain as a fallback
                        ## in case you do not get any results from this server.
                        if( $entryKeywords.Count -eq 1 -and 
[String]::IsNullOrEmpty( $fallBackLdapPath ) )
                        {
                                $fallBackLdapPath = $ptrLdapPath
                                Write-Verbose "Saved fallback SCP pointer 
$fallBackLdapPath"
                        }
                }
                else
                {
                        $server = $entry.Properties[ 'servicednsname' ][0]
                        Write-Verbose "SCP entry for server $server did not 
contain $ScpPtrGuidString"
                }
        }

        [string]$computerSiteName = ''

        try
        {
                $site = 
[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite()
                $computerSiteName = $site.Name
                $site = $null
        }
        catch
        {
                Write-Warning "Error retrieving computer site name 
$($_.ToString())"
                return $null
        }

        if( [String]::IsNullOrEmpty( $computerSiteName ) )
        {
                Write-Verbose "Local computer is in empty site"
                return $null
        }

        Write-Verbose "Local computer in site $computerSiteName"

        ## Scan the search results for SCP URLs

        ## Temporary lists to hold priority 2 and 3 URLs.
        $priority2URLs = @()
        $priority3URLs = @()

        foreach( $entry in $entries )
        {
                $entryKeywords = $entry.Properties[ 'keywords' ]

                ## check for SCP URLs
                if( ( CollectionContainsExactValue $entryKeywords 
$ScpUrlGuidString ) )
                {
                        $scpUrlPath = $entry.Path
                        Write-Verbose "SCP URL found at $scpUrlPath"

                        $scpUrl = $entry.Properties[ 
'servicebindinginformation' ][ 0 ] -as [String]
                        Write-Verbose "SCP Binding Information $scpUrl"

                        $scpUrl = $scpUrl.ToLower()
                        Write-Verbose "SCP Binding Information (lower) $scpUrl"

                        ## Determine whether this entry is scoped to the 
computer's site.
                        if( ( CollectionContainsExactValue $entryKeywords ( 
'Site=' + $computerSiteName ) ) )
                        {
                                ## Priority 1
                                if( $scpUrlList -contains $scpUrl )
                                {
                                        Write-Verbose "Priority 1 SCP URL 
already present in scpUrlList $scpUrl"
                                }
                                else
                                {
                                        Write-Verbose "Priority 1 SCP URL being 
added to scpUrlList $scpUrl"
                                        $scpUrlList += $scpUrl
                                }
                        }
                        else
                        {
                                ## Determine whether this is a priority 2 or 3 
URL
                                if( ( CollectionContainsPrefixValue 
$entryKeywords 'Site=' ) )
                                {
                                        ## Priority 3
                                        if( $priority3Urls -notcontains $scpUrl 
)
                                        {
                                                Write-Verbose "Priority 3 SCP 
URL being added to priority3Urls $scpUrl"
                                                $priority3Urls += $scpUrl
                                        }
                                        else
                                        {
                                                Write-Verbose "Priority 3 SCP 
URL already present in priority3Urls $scpUrl"
                                        }
                                }
                                else
                                {
                                        ## Priority 2
                                        if( $priority2Urls -notcontains $scpUrl 
)
                                        {
                                                Write-Verbose "Priority 2 SCP 
URL being added to priority2Urls $scpUrl"
                                                $priority2Urls += $scpUrl
                                        }
                                        else
                                        {
                                                Write-Verbose "Priority 2 SCP 
URL already present in priority2Urls $scpUrl"
                                        }
                                }
                        }
                }
        }

        Write-Verbose "Before building ordered list, scpUrlLIst (Priority 1) 
contains $($scpUrlList.Count) entries"
        Write-Verbose "Priority2Urls contains $($priority2Urls.Count)"
        Write-Verbose "Priority3Urls contains $($priority3Urls.Count)"

        foreach( $url in $priority2Urls )
        {
                Write-Verbose "Checking $url"
                if( $scpUrlList -contains $url )
                {
                        Write-Verbose "...already present"
                }
                else
                {
                        Write-Verbose "...adding to scpUrlList"
                        $scpUrlList += $url
                }
        }
        $priority2Urls = $null

        foreach( $url in $priority3Urls )
        {
                Write-Verbose "Checking $url"
                if( $scpUrlList -contains $url )
                {
                        Write-Verbose "...already present"
                }
                else
                {
                        Write-Verbose "...adding to scpUrlList"
                        $scpUrlList += $url
                }
        }
        $priority3Urls = $null

        ## If after all this, you still have no URLs in your list,
        ## try the fallback SCP pointer, if you have one.
        if( $scpUrlList.Count -eq 0 -and $fallBackLdapPath -ne $null )
        {
                Write-Verbose "scpUrlList.Count = 0 and fallBackLdapPath 
$fallBackLdapPath"
                Write-Verbose "...trying again"

                return ( GetScpUrls $fallBackLdapPath $domain )
        }

        Write-Verbose "Returning scpUrlList with $($scpUrlList.Count) entries"

        return $scpUrlList
}

###
### Main
###

try 
{
        $urls = GetScpUrls $null $domain
}
catch
{
        $urls = $null
}

" "
"Ordered List of Autodiscover SCP endpoints for $domain"
" "
if( $urls -eq $null -or ( $urls -is [Array] -and $urls.Count -le 0 ) )
{
        "...there are no SCP endpoints for the domain"
}
else
{
        foreach( $url in $urls )
        {
                "    $url"
        }
}
" "
"SCP lookup done"
" "

Reply via email to