Author Posts

July 31, 2018 at 9:57 pm

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?

July 31, 2018 at 10:19 pm

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.

July 31, 2018 at 10:33 pm

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.

August 1, 2018 at 1:22 am

Try Import-Module ServerManager on the remote machine.

August 1, 2018 at 6:34 pm

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?

August 2, 2018 at 4:47 am

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.

August 2, 2018 at 9:31 pm

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?

August 3, 2018 at 9:24 pm

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?

August 3, 2018 at 9:43 pm

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]