what DC has an FTP Feature installed

Welcome Forums General PowerShell Q&A what DC has an FTP Feature installed

This topic contains 9 replies, has 2 voices, and was last updated by

 
Participant
2 months, 4 weeks ago.

  • Author
    Posts
  • #104404

    Participant
    Points: 0
    Rank: Member

    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 |
        more
    }

    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

  • #104407
    MJ

    Participant
    Points: 0
    Rank: Member

    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. 🙂

    Cheers!

    • #104410

      Participant
      Points: 0
      Rank: Member

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

    • #104416
      MJ

      Participant
      Points: 0
      Rank: Member

      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
         
      }
      
    • #104420

      Participant
      Points: 0
      Rank: Member

      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.

    • #104422
      MJ

      Participant
      Points: 0
      Rank: Member

      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.

      Cheers!
      Michael

    • #104423

      Participant
      Points: 0
      Rank: Member

      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.

    • #104425
      MJ

      Participant
      Points: 0
      Rank: Member

      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.

    • #104486

      Participant
      Points: 0
      Rank: Member

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

    • #105092

      Participant
      Points: 0
      Rank: Member

      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 ?

You must be logged in to reply to this topic.