I have this script:
Write-Host " start `n"
Get-LocalUser | Where-Object {$_.Enabled} | Write-Output
Write-Host "end `n"
I want the output to look like this:
start
Name Enabled Description
---- ------- -----------
user True account info
student True account info
end
But for some reason, when I run the script, I get this:
start
end
Name Enabled Description
---- ------- -----------
user True account info
student True account info
Why is it waiting until after the script to display the info, and not doing it where I called the command (i.e. in between "start" and "end")?
I have tried assigning it to a variable and using write-host to print the variable... that did not work.
I also tried using write-host at the beginning instead of piping to write-output... that did not work either.
New to PowerShell scripting, what did I do wrong?