Is there a way in AD or any other way to get all ADFS servers in the company?

SAM2009
SAM2009 used Ask the Experts™
on
Hi,

Is there a way in AD or any other way to get all ADFS servers in the company?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
yo_beeDirector of Information Technology

Commented:
Good evening Sam.

How many do you think your have?
yo_beeDirector of Information Technology

Commented:
from your adfs server run this Powershell command

Get-AdfsFarmInformation

It will list all servers that are part of your ADFS farm.

Author

Commented:
Do I need to install something first? Because I got:

Get-AdfsFarmInformation : The term 'Get-AdfsFarmInformation' is not recognized
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

yo_beeDirector of Information Technology

Commented:
Sorry.  This is a 2016 ADFS command.
If you are running ADFS on a server 2016 you should be able to run this from there.

Try this to confirm if the ADFS module is loaded.

Get-Command *ADFS*

Open in new window

Author

Commented:
yes but get commands are limited to:

Cmdlet          Get-ADFSAttributeStore
Cmdlet          Get-ADFSCertificate
Cmdlet          Get-ADFSClaimDescription
Cmdlet          Get-ADFSClaimsProviderTrust
Cmdlet          Get-ADFSConfiguration
Cmdlet          Get-ADFSEndpoint
Cmdlet          Get-ADFSProxyConfiguration
Cmdlet          Get-ADFSRelyingPartyTrust
Cmdlet          Get-ADFSSyncConfiguration
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
That will only get you servers within the ADFS farm.

You will probably have to check all servers if role is installed

Commented:
Yes, like the below script for example:

$domain= 'DOMAIN\Username'
$pass=ConvertTo-SecureString -String 'YourPassword' -AsPlainText -Force
$creds=New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

(Get-Content C:\Servers.txt| `
Foreach{Invoke-Command -ComputerName $_ -Verbose -ScriptBlock{get-windowsfeature | `
Where-Object{$_.installed -eq $true -and $_.featuretype -eq 'Role'} |   
select name, installed -ExcludeProperty subfeatures} -Credential $creds}) | `
Format-Table -Property Name, Installed, @{name='Server Name';expression={$_.pscomputername}} -AutoSize

Open in new window


You can Export the data into an excel file by piping the last cmdlet of the script into Export-CSV cmdlet.

Note:  ADFS role: adfs-federation
This Script just gives you Installed Roles, Not the installed features.
To include features as well in the results, please remove the -and $_.featuretype -eq ‘Role’ from the script
yo_beeDirector of Information Technology

Commented:
I like IT suggestion. I would take that and replace the get-content block with

Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")}
yo_beeDirector of Information Technology

Commented:
Also why do you think you have more than one ?
Commented:
Here it is the updated script:

$domain = 'DOMAIN\Username'
$pass = ConvertTo-SecureString -String 'YourPassword' -AsPlainText -Force
$creds = New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

( Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")} `
        ForEach-Object {Invoke-Command -ComputerName $_ -Verbose -ScriptBlock {
            Get-WindowsFeature | `
                Where-Object {$_.installed -eq $true -and $_.Name -eq 'ADFS-Federation' -and $_.featuretype -eq 'Role'} |   
                Select-Object name, installed -ExcludeProperty subfeatures
        } -Credential $creds}) | `
    Format-Table -Property Name, Installed, @{name = 'Server Name'; expression = {$_.pscomputername}} -AutoSize

Open in new window

Author

Commented:
Thanks all for your help!
yo_beeDirector of Information Technology

Commented:
Did you find any other rogue ADFS servers ?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial