Is Get-WindowsFeature deprecated?

Welcome Forums General PowerShell Q&A Is Get-WindowsFeature deprecated?

This topic contains 8 replies, has 3 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #105706

    Participant
    Points: 48
    Rank: Member

    I'm trying to run a remote call to servers using Get-WindowsFeature and everything I see via Google searches shows that Get-WindowsFeature has a -computerName parameter, yet on my WMF 5.1 2008 R2 utility server, I only see a -Name parameter and that's for the Role or feature I want information on.

    NAME
        Get-WindowsFeature
        
    SYNOPSIS
        The Get-WindowsFeature cmdlet allows you to retrieve information about 
        roles, role services, and features that are available on a computer that 
        is running Windows Server 2008 R2.
        
        
    SYNTAX
        Get-WindowsFeature [[-Name] ] [-logPath ] []

    Not terribly useful is a local return:

     Get-WindowsFeature -Name Web-Ftp-Server
    
    Display Name                                            Name                   
    ------------                                            ----                   
        [ ] FTP Server                                      Web-Ftp-Server

    I was hoping to perhaps run Invoke-Command with this cmdlet to glean info on what's installed on rmeote servers.

    Alternately, I was thinking if I had a local text file that had listed the following Roles or features:

    Web-Ftp-Server
    Web-Ftp-Service
    Web-Ftp-Ext

    ...if it could read from my utility server, then essentially query for those Feature Roles on my array of remote computers then return TRUE/FALSE.

    This sounds tremendously useful but if the Cmdlet doesn't exist yet, is there another way?

  • #105709

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    It's not deprecated, but it's changed over time. You can certainly use it with Invoke-Command. Note that the default “checkbox” display is just a display thing – the output is object-based, not text-based. If you pipe it to “Format-List -Prop *”, for example, you'll get the “raw” output. One of the output properties is a True/False one that showed if it's installed or not.

    • #105710

      Participant
      Points: 48
      Rank: Member

      ok so this then, right?

      Get-WindowsFeature -Name Web-Ftp-Server | fl -Property Installed,Name,SubFeatures
      
      
      Installed   : False
      Name        : Web-Ftp-Server
      SubFeatures : {Web-Ftp-Service, Web-Ftp-Ext}

      Will test it with invoke-command thanks Don

      [update]

      ok I have this:

      Invoke-Command -ComputerName DCS001.corp.com {
          Get-WindowsFeature -Name Web-Ftp-Server | fl -Property Installed,Name,SubFeatures
      }

      ...but get the error "The term 'Get-WindowsFeature' is not recognized as the name of a cmdlet".

      I must be misunderstanding remoting even though I've read the freebie "Secrets to Powershell remoting"

      I thought that if I had my Utility server with the latest PS cmdlets, I could leverage any of them to query against any server in the domain regardless if those remote servers only had PS 2.0 installed. Is this a mistaken assumption?

      If so, then I'd have to update WMF on hundreds of server to get this kind of information about what's installed on a remote server for example.

    • #105893

      Participant
      Points: 48
      Rank: Member

      Don,

      What I don't understand is that on MS site for Get-WindowsFeature here: https://docs.microsoft.com/en-us/powershell/module/servermanager/get-windowsfeature?view=winserver2012r2-ps

      ...it lists [-ComputerName ] as a parameter, yet I have WMF 5.1 installed and do not get that parameter.

      SYNTAX
          Get-WindowsFeature [[-Name] ] [-logPath ] []

      Who is out of date?

  • #105715

    Participant
    Points: 7
    Rank: Member

    Try Import-Module ServerManager on the remote machine.

    • #105757

      Participant
      Points: 48
      Rank: Member

      Richard,

      this does return data:

      Invoke-Command -ComputerName dcs006,dcs007,dcs001,dcs002 {
          Get-WindowsFeature -Name Web-Ftp-Server | fl -Property Installed,Name,SubFeatures
      }

      But I can't tell which host has what:

      Installed   : False
      Name        : Web-Ftp-Server
      SubFeatures : {Web-Ftp-Service, Web-Ftp-Ext}
      
      
      
      
      
      Installed   : False
      Name        : Web-Ftp-Server
      SubFeatures : {Web-Ftp-Service, Web-Ftp-Ext}
      
      
      
      
      
      Installed   : False
      Name        : Web-Ftp-Server
      SubFeatures : {Web-Ftp-Service, Web-Ftp-Ext}
      
      
      
      
      
      Installed   : False
      Name        : Web-Ftp-Server
      SubFeatures : {Web-Ftp-Service, Web-Ftp-Ext}

      ..how would I populate the PSComputerName in the results?

    • #105899

      Participant
      Points: 48
      Rank: Member

      Richard,

      So the remote DC is running PS 2.0 and you're right, servermanager wasn't loaded, so I imported that module on the remote DC, confirmed it can run Get-WindowsFeature, then I go back to my scripting host and run your revised snippet and it still fails for those 2 DC's.

      The term 'Get-WindowsFeature' is not recognized as the name of a cmdlet

       

      [ ed. This was addressed in another thread on how to use Import-Module ServerManager in an Invoke-Command statement]

  • #105773

    Participant
    Points: 7
    Rank: Member

    Jeff,

    This will show the PSComputerName property in the results:

    Invoke-Command -ComputerName dcs006,dcs007,dcs001,dcs002 {
        Get-WindowsFeature -Name Web-Ftp-Server | select-property PSComputerName,Installed,Name,Subfeatures 
    } 
    

    Pipe your scriptblock command to select-property instead of fl. Then, add PSComputerName to the list of properties you want displayed.

    • #105830

      Participant
      Points: 48
      Rank: Member

      Nice, that worked thank you. What wasn't intuitive to me was that the NoteProperty (PSComputerName) is found outside the curly braces, part of the Invoke-command cmdlet.

      yet, the select -property is piped from the Get-WindowsFeature cmdlet inside the curly braces.

      How is it that the parent NoteProperty can be selected/outputted inside the braces?

The topic ‘Is Get-WindowsFeature deprecated?’ is closed to new replies.