locked
search Windows core servers in Active Directory RRS feed

  • Question

  • Hello there,

    I tried to write a script to list all Windows core servers in my domain. I used the following commands. It worked very slow because it needed to load the features from every servers. Do you have a doable solution? Thanks a lot!

    $computeNames = Get-ADComputer -Filter {OperatingSystem -Like "*Server*"} -Properties Name
    foreach ($name in $computeNames.Name) {
       Get-WindowsFeature -ComputerName $name | Where-Object {$_.Name -eq 'Server-Gui-Shell'}
     }
    Tuesday, December 19, 2017 9:44 PM

Answers

  • Get-WmiObject Win32_OptionalFeature -Filter "name='Server-Gui-Shell'" -ComputerName <remoteserver>

    \_(ツ)_/

    • Marked as answer by John.Li-20841 Wednesday, December 20, 2017 4:31 PM
    Wednesday, December 20, 2017 3:32 AM

All replies

  • Don't use Where-Object.

    Get-WindowsFeature Cmdlet has a Name parameter. (Name parameter doesn't support wildcard)

    Technet Get-WindowsFeature

    Get-WindowsFeature -ComputerName $name -Name 'Server-Gui-Shell'

    Tuesday, December 19, 2017 10:04 PM
  • Thanks, Vincent.

    Get-WindowsFeature -ComputerName $name -Name 'Server-Gui-Shell' works.

    However, the Windowsfeature loading for every server takes more time.

    Wednesday, December 20, 2017 3:22 AM
  • Get-WmiObject Win32_OptionalFeature -Filter "name='Server-Gui-Shell'" -ComputerName <remoteserver>

    \_(ツ)_/

    • Marked as answer by John.Li-20841 Wednesday, December 20, 2017 4:31 PM
    Wednesday, December 20, 2017 3:32 AM