Archive for the ‘Powershell’ Category.
April 5, 2010, 8:50 pm
Occasionally it is necessary to prompt a user for input in a Powershell script. In my case I just need to remind the user to do something, but the same command can get the user input and store it in a variable.
$input=read-host "Hey user, enter some text!"
The text that enters in the above example is save in the $input variable.
March 31, 2010, 8:45 pm
For my research I found the need to automatically visit a webpage to run a setup and a teardown script. Turns out that it is fairly easy to do. The script is included below.
#cd to Internet Explorer
cd "C:\Program Files\Internet Explorer"
#point ie to the teardown script
./iexplore.exe 10.0.0.20/teardown.php
#sleep for one second - this is needed so IE has a chance to start before it is killed
sleep 1
#kill the internet explorer process
get-process iexplore | stop-process
March 16, 2010, 6:05 pm
I have been doing a lot of powershell scripting for my senior thesis. I had the need to run a background job and did not find helpful information through searching Google so I figured I would post this.
Powershell 2 support running scripts in the background with a simple command. The only caveat is that it will only run other powershell scripts.
Start a background job: $job=start-job “script.ps1″
Wait for the job to finish: wait-job($job)