How to Search Windows Servers 2012 R2 Roles & Features (Installed / Not Installed)

 

Step: 1

 

Create TXT File

Write your Server Machine Names:

 Server1

Server2

Server3

 

Copy this File in C Drive with Path like C:\Servers.txt

Step: 2

Add your Domain Name & Credentials in Script

Query the Roles Installed On Servers:

$domain= 'Microtechx\Administrator'

$pass=ConvertTo-SecureString -String 'Mcse2009' -AsPlainText -Force

$creds=New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

 

(Get-Content C:\Servers.txt| foreach{Invoke-Command -ComputerName $_ -Verbose -ScriptBlock{get-windowsfeature | ?{$_.installed -eq $true -and $_.featuretype -eq 'Role'} | select name, installed -ExcludeProperty subfeatures} -Credential $creds}) | ft -Property Name, Installed, @{name='Server Name';expression={$_.pscomputername}} -AutoSize

 

 

Output:

 

Query the Roles Not Installed On Servers:

You have to put False at place of True Argument:

$_.installed -eq $true  with $_.installed -eq $False

$domain= 'Microtechx\Administrator'

$pass=ConvertTo-SecureString -String 'Mcse2009' -AsPlainText -Force

$creds=New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

 

(Get-Content C:\Servers.txt| foreach{Invoke-Command -ComputerName $_ -Verbose -ScriptBlock{get-windowsfeature | ?{$_.installed -eq $False -and $_.featuretype -eq 'Role'} | select name, installed -ExcludeProperty subfeatures} -Credential $creds}) | ft -Property Name, Installed, @{name='Server Name';expression={$_.pscomputername}} -AutoSize

 

 

 

 

Step: 3

Find Feature Installed On Servers:

Replace Role with Feature -eq 'Role'-eq 'Feature'

$domain= 'Microtechx\Administrator'

$pass=ConvertTo-SecureString -String 'Mcse2009' -AsPlainText -Force

$creds=New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

 

(Get-Content C:\Servers.txt| foreach{Invoke-Command -ComputerName $_ -Verbose -ScriptBlock{get-windowsfeature | ?{$_.installed -eq $true -and $_.featuretype -eq 'Feature'} | select name, installed -ExcludeProperty subfeatures} -Credential $creds}) | ft -Property Name, Installed, @{name='Server Name';expression={$_.pscomputername}} -AutoSize

 

 

 

 

Find Features Not Installed on Servers:

 

$_.installed -eq $true  with $_.installed -eq $False

$domain= 'Microtechx\Administrator'

$pass=ConvertTo-SecureString -String 'Mcse2009' -AsPlainText -Force

$creds=New-Object System.Management.Automation.pscredential -ArgumentList $domain, $pass

 

(Get-Content C:\Servers.txt| foreach{Invoke-Command -ComputerName $_ -Verbose -ScriptBlock{get-windowsfeature | ?{$_.installed -eq $False -and $_.featuretype -eq 'Feature'} | select name, installed -ExcludeProperty subfeatures} -Credential $creds}) | ft -Property Name, Installed, @{name='Server Name';expression={$_.pscomputername}} -AutoSize