Invoke-Command list of servers not sorted

Reading computer names from a file. Input file srv.txt lists servers in alphabetical order
Output ist not sorted as it is in the text file. Is there a way to get output as listed in the text file?

$Srv = Get-Content -Path "D:\Srv.txt"

Invoke-Command -ComputerName $Srv -ScriptBlock {
    $Comp = Get-WmiObject -Class Win32_ComputerSystem
    $Comp.Name

}

If all you are after is that the output is sorted, you should be able to just pipe the output to Sort-Object

$Srv = Get-Content -Path "D:\Srv.txt"

Invoke-Command -ComputerName $Srv -ScriptBlock {
    $Comp = Get-WmiObject -Class Win32_ComputerSystem
    $Comp.Name

} | Sort-Object -Property Name

Be aware that piping to sort, means that the entire list of servers will be processed, before you see any output (needs to get all objects through the pipe, before it can do any sorting).

Keep in mind that Invoke-Command runs parallel, and different computers will respond differently, which is why the sequence changes. Personally I’d put the results in a database - much easier to pull sorts and mess with the data!

Keep in mind that Invoke-Command runs parallel, and different computers will respond differently, which is why the sequence changes. Personally I’d put the results in a database - much easier to pull sorts and mess with the data!

Keep in mind that Invoke-Command runs parallel, and different computers will respond differently, which is why the sequence changes. Personally I’d put the results in a database - much easier to pull sorts and mess with the data!