what DC has an FTP Feature installed

This topic contains 8 replies, has 2 voices, and was last updated by  Jeff Taylor 6 days, 4 hours ago.

  • Author
    Posts
  • #104404

    Jeff Taylor
    Participant

    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

    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

      Jeff Taylor
      Participant

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

    • #104416

      MJ
      Participant

      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

      Jeff Taylor
      Participant

      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

      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

      Jeff Taylor
      Participant

      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

      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

      Jeff Taylor
      Participant

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

You must be logged in to reply to this topic.