If you install Roles and Features with PowerShell, Install-WindowsFeature is your friend. Get-Windowsfeature gets information about installed or available Server Roles. This blog post shows you how to get a list of all installed Roles on Windows Server 2012 or Windows Server 2016.
First of all, I want point out that there is a newer blog post that enables you to retrieve all server roles from all servers. More here: List all Server Roles from all Windows Servers with PowerShell
Get-WindowsFeature
Running without parameters, Get-WindowsFeature gets information about all Server Roles and Features. We are looking for the attribute installstate. Possible values are: Installed, Available, Removed.
List all installed Features and Roles
Let´s move on. I am logged on Server03, which is a Member Server of my Domain. I search for all installed Roles on the localhost.
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate | more
List all roles and Features on a Remote Host
As mentioned, I am logged on Server03. Let´s find all installed Roles and Features on the remote computer dc01. Server03 and dc01 are in the same domain. I use Get-WindowsFeature with the parameter -ComputerName.
Get-WindowsFeature -ComputerName dc01 | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate | more
See also
For installing and listing Windows Server Roles and Features you can also establish a PowerShell Remote Session, which i described in this article: How to configure Trusted Hosts for PowerShell Remote Sessions.
Categories: PowerShell, Windows Server
Why don’t use this simple command, instead your last command:
Get-WindowsFeature -Name web-* | Where installed
LikeLike
Thank you. This also works. I want to show the entire command to my readers.
LikeLike
can you please tell me with example?
LikeLike
how to get roles only without features?
LikeLike
there is a option that i can map my all the server`s in my domain ?
LikeLike
but if it doesn’t give me a list? Returns ‘ntProviderException’.
LikeLike
Did you run it on a Windows Server? OS? Best, P
LikeLike