Running a CMD command on multiple Windows Servers

I ran into a project at work that requires me to check the server version of over 200 servers. I was wondering if anyone can help me with some information on how to get this done, i've seen a couple example thus far but none that really fit my requirements.

I want to run "DISM /online /Get-CurrentEdition" across the server list and output that information into a text file.

Parents
  • May I suggest another way? Use Get-CimInstance, it was meant to do things like this. Here is some sample code:

    $Computers = 'server2019', 'server2016'
    Get-CimInstance -ClassName win32_operatingsystem -ComputerName $computers |
        Select-Object -Property CsName, Caption, Version, OSArchitecture
    
    
    CsName     Caption                                Version    OSArchitecture
    ------     -------                                -------    --------------
    SERVER2019 Microsoft Windows Server 2019 Standard 10.0.17763 64-bit
    SERVER2016 Microsoft Windows Server 2016 Standard 10.0.14393 64-bit
    
Reply
  • May I suggest another way? Use Get-CimInstance, it was meant to do things like this. Here is some sample code:

    $Computers = 'server2019', 'server2016'
    Get-CimInstance -ClassName win32_operatingsystem -ComputerName $computers |
        Select-Object -Property CsName, Caption, Version, OSArchitecture
    
    
    CsName     Caption                                Version    OSArchitecture
    ------     -------                                -------    --------------
    SERVER2019 Microsoft Windows Server 2019 Standard 10.0.17763 64-bit
    SERVER2016 Microsoft Windows Server 2016 Standard 10.0.14393 64-bit
    
Children
No Data