For all of you busy SharePointers out there, this may be a helpful addition to your PowerShell scripts. Adding an input box to a script allows it to be reusable instead of only for a certain web app, site collection, or site. Think of it as an interactive way of passing parameters into PowerShell commands. It’s simple and easy, here’s how:
Add to the top of your script:
[void][System.Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’)
Call the input box and store the results in a variable:
$var_name = [Microsoft.VisualBasic.Interaction]::InputBox(“Input Description”, “Window Title”)
Use the variable where needed in your PowerShell script:
Get-SPLogEvent| ?{$_.level –eq $var_name} | select Category, Message | more
Example:
Voila!
10/29/2009
PowerShell