Add an Input Box to Your SharePoint 2010 PowerShell Scripts



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:


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





Subscribe to our RSS feed and social profiles to receive updates.

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: