I'm writing a simple script which displays a menu where one can choose from various scripts. One of those scripts should return the location which got a user account locked.
The script I want to use is this one here: https://gallery.technet.microsoft.com/scriptcenter/Get-LockedOutLocation-b2fd0cab
I added three lines to the end of the script so that I can read the output before the window gets closed:
$username = Read-Host 'Please enter a username'
Get-LockoutLocation -Identity $username
Read-Host 'Press a key to quit'
The script gets executed with this command:
start powershell -ArgumentList '.\get-lockout-location.ps1'
When I execute the script it first returns the domain controller which locked the account. However the next thing which appears is the line which asks for a key press to quit. And at the end comes the output from the event log.
Does someone know what I have to change so that the key press lines is the last thing that appears? I tried already quite a lot of things (executing from a different file, piping the output, removing the process part, putting the Read-Host line to a different position)and none of it worked.