question

NaveenKumar-9435 avatar image
0 Votes"
NaveenKumar-9435 asked LimitlessTechnology-2700 answered

Get list of installed features and roles on all domain servers - Powershell

Get list of installed features and roles on all domain servers - Powershell

Get-ADComputer -Filter 'operatingsystem -like "server" -and enabled -eq "true"' `
-Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address |
Sort-Object -Property Operatingsystem |
Select-Object -Property Name,Operatingsystem,OperatingSystemVersion,IPv4Address|Export-Csv c:\temp\allservers.csv -NoTypeInformation

above command is giving servers name, which looks good but when i run below command it gives me only one computer (last name in allservers.csv) role and feature info , i need all servers list of installed features and roles

$lists=Import-Csv c:\temp\allservers1.csv
foreach($list in $lists){
Get-WindowsFeature -ComputerName $list.name | Where-Object {$_. installstate -eq "installed"} |
select Name,Installstate | export-csv c:\temp\pelicanservers1-roles.csv -NoTypeInformation
}

above command should give role and feature info for all servers which is mentioned in allservers.csv and export file pelicanservers1-roles.csv should have servers name as well for which role and feature is associated with.

Thanks in advance for help!

windows-server-powershellwindows-active-directory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered DSPatrick commented

You can follow along here.
http://woshub.com/install-remove-windows-server-roles-features-powershell/

--please don't forget to upvote and Accept as answer if the reply is helpful--



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Just checking if there's any progress or updates?

--please don't forget to upvote and Accept as answer if the reply is helpful--



0 Votes 0 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello

Thank you for your question and reaching out.
I can understand you are having some issues related to get installed features and roles on all servers.

You can try below powershell code block assimung that WinRM and RPC is enabled.



 (Get-Content .\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}} | Export-Csv info.csv -NoTypeInformation






--If the reply is helpful, please Upvote and Accept as answer--



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.