Here is my script:
Get-WmiObject -Class win32_LoadOrderGroupServiceMembers |
ForEach-Object {
New-Object -TypeName psobject -Property `
@{
"GroupOrder"=([wmi]$_.GroupComponent).GroupOrder
"GroupName"=([wmi]$_.GroupComponent).Name
"ServiceName"=([wmi]$_.PartComponent).Name
"Started"=([wmi]$_.PartComponent).Started
}
} |
Where-Object { $_.started } | Sort-Object -Property grouporder -Descending
Read-Host -Prompt "Any key to exit:"
The problem is that when I execute it (double click on file), it halts on Read-Host -Prompt, but when I press enter it prints the results very briefly and then the window automatically closes.
How can I get the results of Get-WmiObject
and Where-Object
to print onscreen before the Read-Host -Prompt "Any key to exit:"
?
I am somewhat new to Powershell scripting so go easy on me.