what DC has an FTP Feature installed

I made this script to discover all features installed on our DCs but can’t figure out how to associate the hostname with the installed feature(s). When I do get-member I see name but that is the name of the feature, not the "name"s contained in my pipeline variable.

$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ } | select Name

foreach ($DC in $allDCs) {
    Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} |
    Format-List DisplayName,Installstate |

Once I know the name of the feature I’m actually looking for (a forgotten ftp server) I will modify my Where-Object construct.

Thank you

Store results of Get-windowsfeature to a var, then write-output $DC + $Features within the foreach?

#Sorry for not doing actual code, just flowing it out. :slight_smile:


Thanks but that’s a bit over my head to translate what you’re actually suggesting.

Ok, I’ll give it a go. My copy/paste feature is broken apparently. :p. I know this isn’t the most efficient way AT ALL, but my brain is on fumes atm…so apologies. Try this?

$DCs=(get-adforest).domains | foreach {Get-ADDomainController -Filter * -Server $_ }

foreach ($dc in $dcs){
    write-output $dc.name
    Get-WindowsFeature -computername $dc | where installstate -eq "installed" | select name,installstate

Thanks, I had to change the Get-WindowsFeature parameter from -computer $dc to -Name $dc to remove wrong parameter error and get output but it only output the DC hostname and nothing else. No column for installstate i.e. and no values.

What I had worked in my environment. Only 1 DC, but worked regardless. Proof of concept. Not sure what you need for output. I like using name parameter for extracting the feature name.


Yeah I get it to work locally too but I don’t think it works for the pipeline or maybe need to use Invoke-command in a PSsession.

I ran it in a domain from a non-DC, if the cmdlet has the -computername parameter (as get-windowsfeature has), it typically has the ability to retrieve remote info (assuming domain…otherwise, need to modify trustedhosts file). Your original code isn’t specifying -computername. That is where you enter -computername $dc. Otherwise, it defaults to localhost.

ah, my server has PS 3.0 and so only has -Name parameter. Let me update WMF and try again

I upgraded to WMF 5.1 but Get-WindowsFeature still has only a -Name parameter.

Get-WindowsFeature : A parameter cannot be found that matches parameter name 'computerName'.

How did you get it to offer -ComputerName ?