Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, May 30, 2017 1:32 PM
Hi,
i need to list all of servers in our domain which have to do something with RDS role. Searched on the internet but did not find anything remotely similar.
Would it work with the Get-WindowsFeature cmdlet?
Thank you,
All replies (7)
Wednesday, June 7, 2017 11:00 AM ✅Answered
Hi Tonito,
I made a simple script. Could you check if this is what you need?
#Location of the servers.txt file.
$Serverlist = Get-Content "C:\Servers.txt"
foreach($Server in $Serverlist)
{
Get-WindowsFeature RDS-RD-Server -ComputerName $Server | Select-Object @{n='ServerName';e={$Server}},Installed
}
The output will be like:
ServerName Installed
Server1 True
Server2 True
Server3 False
Server4 True
Server5 False
Server6 True
Wednesday, June 7, 2017 7:44 AM
Hi,
thank you for you answer but unfortunately everything you wrote did not provide me with the results i am looking for. Get-WindowsFeature -Name *RDS* - works for local sever yes, but i need a list of server containing the RDS roles. Even the two provided links on which i have spent 30min testing did nothing worth mentioning.
Anyway thanks,
Wednesday, June 7, 2017 8:09 AM
Here is the tool that can do this: https://technet.microsoft.com/en-us/library/jj205469(v=wps.630).aspx
** Get-WindowsFeature RDS-RD-Server -ComputerName $computer**
\(ツ)_/
Wednesday, June 7, 2017 9:07 AM
Hi jrv,
the cmdlet is well known to me but i really need the whole working script. Battling for 3 hours now with loops and hops.
So i got a list of server in .txt and the script should read the names of the servers and at the same time check if the RDS role is installed. For the output, it should show computername and if possible rds role.
Thanks,
Wednesday, June 7, 2017 11:14 AM
Hi JdG89,
it works! Thanks you very much, this can be re-used for other roles. One more question, Windows before 2012 will not work? is there a way around this limitation?
I came up with a script also but it is clumsy in terms of displaying data:
$a=Get-Content "C:\users\xyz\desktop\servers.txt";
foreach ($i in $a) {
Write-Host $i
get-windowsfeature -ComputerName $i | where {$_.installed -eq $true -and $_.Name -eq 'Remote-Desktop-Services'} | fl Name,installed;
if($b) {
Write-Host $i : 'Yes'
}
else {
Write-Host $i : 'No'
}
}
Working on a better display solution ATM...
Wednesday, June 7, 2017 11:49 AM
Hi Tonito,
Server 2008 R2 does not support the -computername parameter for this cmdlet. You could use a workaround like Invoke-command to run Powershell commands on a Remote Server. The script will be:
$Servers = Get-Content ".\Servers.txt"
foreach($Server in $Servers)
{
Invoke-Command -ComputerName $Server -ScriptBlock {Get-WindowsFeature RDS-RD-Server | Select-Object PSComputerName, Installed }
}
Tuesday, December 4, 2018 9:32 AM | 1 vote
You can also use gmwi to get the information:
gwmi -Class Win32_ServerFeature -ComputerName $Server.name -Property * -ErrorAction Stop |
where { $_.Name -like "Remote Desktop Services" }
I got the following error on some servers using "Get-WindowsFeature RDS-RD-Server -ComputerName $HostName | Select-Object @{n='ServerName';e={$HostName}},Installed"
Get-WindowsFeature : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet.