I have got the request to figure out on which servers the Desktop Experience Feature is installed. Our environment contains only Windows 2008R2 and Windows 2012R2 servers.
Checking all servers one by one is a hell of a job, so I decided to create this script. The scripts uses Powershell Remote to connect to the target servers, so this needs to be enabled on all target servers.
The target servers are defined in the Servers.txt file. Then the script executes the invoke-command to see if the feature is installed. If the feature is installed, the server will be added to the FeatureInstalled.txt otherwise the
server will be added to the FeatureNOTInstalled.txt file.
#Read the servers.txt file, this file contains all the servers that needs to be checked. $Servers = Get-Content D:\PowerShell\Servers.txt #Define the log file locations for the installed and not installed files: $InstalledFile = D:\PowerShell\FeatureInstalled.txt $NotInstalledFile = D:\PowerShell\FeatureNOTInstalled.txt #Check if the log FeatureInstalled.txt exits, if not, then create it if(!(Test-Path -Path $InstalledFile)){ New-Item -Path $InstalledFile -ItemType File } #Check if the log FeatureNOTInstalled.txt exits, if not, then create it if(!(Test-Path -Path $NotInstalledFile)){ New-Item -Path $NotInstalledFile -ItemType File } #Connect to each server to see if Desktop-Experience is installed, if installed add computer name to FeatureInstalled.txt otherwise add computer name to FeatureNOTInstalled.txt Foreach($Server in $Servers){ $FeatureInstalled = Invoke-Command -ComputerName $Server -ScriptBlock { import-module ServerManager ; Get-WindowsFeature Desktop-Experience } if ( $FeatureInstalled.Installed -eq $true ){ Add-Content $InstalledFile -Value $Server } elseif ( $FeatureInstalled.Installed -eq $false ){ Add-Content $NotInstalledFile -Value $Server } }