Scripto Bobble-head Games Logo

Welcome to PoshCode and the 2011 Scripting Games!

The Scripting Games are a special event put on by the Microsoft scripting guys. Script submissions, grading, and script archives are hosted by PoshCode.org. You may want to check out the Official Rules, and the Scripting Games Information page for event information and contest details, since this site is purely for submitting your contest entry!

Remember: You will not be able to see other user's scripts until after the deadline for an event has passed, and you will not be able to submit scripts for an event once that event has passed.

Note: If you have any problems logging in, please clear your cookies. If you still have problems, please use the "Contact Us" tab above or post directly on GetSatisfaction.

Searching for Scripts

  • Find-PrivateBuilds by Andrew Mello 05 Apr 2011 02:28 AM UTC
    by 3 users

    Beginner Event 1
    4 Comments

    Checks if an application is a "Private Build" based on a running process. One or more computer names/addresses can be passed as an array and will be converted to the computer name. Default = "localhost" If a program name is not supplied notepad will be checked.

  • Get-DriverInfo by Kazun 04 Apr 2011 12:35 PM UTC
    by 5 users

    Advanced Event 1
    2 Comments

    Advanced Event 1: Finding Process Module Versions by Using PowerShell

  • Test-Win7Requirements by Jason Hofferle 09 Apr 2011 10:41 PM UTC
    by 2 users

    Advanced Event 5
    3 Comments

    This script is based on the Test-Win7Requirements function. This function uses WMI to check the processor, memory and free disk space to verify they meet the requirements to run Windows 7. The dxdiag utility is used to determine video card capabilities. The official Windows 7 requirements are used as the default values to check against, but different values can be specified through parameters.

  • New-TempFileContent by Rich Kusak 22 Apr 2011 04:58 AM UTC
    by 3 users

    Advanced Event 10
    2 Comments

    The New-TempFileContent function creates a temporary file in the Windows temp location and saves content in the file. Optionally, the file contents can be shown by use if the -Show parameter.

  • Get-LoggedEvent by Jason Hofferle 06 Apr 2011 09:24 PM UTC
    by 3 users

    Advanced Event 3
    2 Comments

    This script is based around the Get-LoggedEvent function. This function was designed with the intent that gathering a list of computer names and formatting output would be done by other cmdlets in the pipeline. These type of tasks gain so much speed through PowerShell remoting that an optional parameter was added that will use fan-out remoting instead of querying each computer individually.

  • Show-Picture by Bartek Bielawski 18 Apr 2011 11:03 AM UTC
    by 2 users

    Advanced Event 8
    3 Comments

    I tried to make this script well.... perfect. ;) * It uses WPK and PSImage Tools from PowerShellPack * If you run it on computer that does not have it - it will give a try and download/ install it from network. * On XP and alike it may fail due to absence of WIA.ImageFile COM Object. It tries to create it early in the script and informs about issue. Gives a link to page where you can get it. * As XP does not support some features of WPF (been there...) it will warn about it if XP is 'detected'. * All controls are transparent, so the picture consumes as much window space as you give to it. It will grow together with window. * Some basic help available inline, more in GUI (press F1 to see it, may fail if network is not available, or at least won't be able to show one picture... ;) * Two parameters -Force (to force it work in MTA powershell.exe and Path to work around the problem of empty pictures folder) - use either. * I know it is huge, but I wanted to cover all scenarios and make it really pretty.... ;) And comment what I do here and there...

  • Beginner10.ps1 by Sadie Trest 22 Apr 2011 04:34 AM UTC
    by 3 users

    Beginner Event 10
    1 Comments

    This script creates a reusable function that executes either the default command or a user supplied command a specified number of times, averages the amount of time each command took to run and returns a string containing the result in milliseconds.

  • Out-Temp by Miklos Karasz 21 Apr 2011 09:59 PM UTC
    by 2 users

    Advanced Event 10
    1 Comments

    The Out-Temp function sends output to a temporary file. Displays the content in notepad if -Notepad specified. Character encoding can be altered from the default ASCII. The temporary file will not be deleted if -Keepfile is specified. You can pipe string or objects also.

  • New-TemporaryFile by Boe Prox 22 Apr 2011 02:37 AM UTC
    by 2 users

    Advanced Event 10
    1 Comments

    In at the last minute...kind of like last year. This command takes the original requirements of creating a temp file on the user's temp folder that accepts data from the pipeline if used and supports whatif,verbose and debug. After creation of the file, the file path and name is displayed. An option to open the file can be performed using the -DisplayFile switch. In its default state, you can run the command and it will automatically generate a file and save it to your temp folder. Because I felt that was sort of a limited feature, I added the ability to state your own destination path and file if needed. An additional feature is that if the folder path does not exist at the time, the folders will automatically be created for you. Also added is the option to determine what type of encoding you wish to use using the -Encoding parameter and supplying the proper encoding name. When added to a profile, this function will be visible for use.

  • Beginner10_2011.ps1 by Neil Clinch 21 Apr 2011 08:01 PM UTC
    by 2 users

    Beginner Event 10
    1 Comments

    Measure the average accuracy of the Start-Sleep command by performing a number of runs for a specified duration of seconds. Then display the average amount of time in milliseconds.

  • Get-ServiceAccounts.ps1 by Daniel Cruz 13 Apr 2011 08:40 PM UTC
    by 2 users

    Beginner Event 4

    Reports any service using a non-standard account on a single or multiple computers. If the All switch is used, all services and accounts will be returned for the computer specified. Standard accounts are defined as "LocalSystem", "NT AUTHORITY\LocalService" and "NT AUTHORITY\NetworkService".

  • Write-Temp by Milo 16 Apr 2011 05:10 AM UTC
    by 2 users

    Advanced Event 10
    5 Comments

    The 2011 Scripting Games Advanced Event 10: Use PowerShell to Create a Function to Create Temp Files

  • beginner 10 by Chris Seiter 21 Apr 2011 08:56 PM UTC
    by 2 users

    Beginner Event 10
    2 Comments

    report back average time a command was run for a specified number of times.

  • Beginner_10_2011.ps1 by David Temple 21 Apr 2011 11:56 PM UTC
    by 2 users

    Beginner Event 10
    2 Comments

    SYNOPSIS Finds the Average Milliseconds for a CMDLET or Oneliner. DESCRIPTION The Script will process a provided CMDLET or Onliner and determine the Average Millisecond Time it took for PowerShell to run it. IT IS IMPORTANT TO SURROUND THE VALUE OF CMDLET WITH SINGLE QUOTES. PLEASE SEE THE EXAMPLES. After the process finishes it will report the following for example: "Average time of 5 runs of 5 seconds is 4998.5468 milliseconds." PARAMETERS -Iterations Iterations indicates how many times this process will loop through the provided CMDLET or Oneliner (Note: The default value is "5") -CMDLET Name of the CMDLET (with or without Parameters) and or a Oneliner. IT IS IMPORTANT TO SURROUND THE VALUE OF CMDLET WITH SINGLE QUOTES. (Note: You must enter a CMDLET Parameter. It is Mandatory and will prompt you if you forget. Again if you use a CMDLET with Parameters or you are using a Oneliner, surround the CMDLET Value with Single Quotes. See Examples) EXAMPLE .\Beginner_10_2011.ps1 -Iterations 5 -CMDLET 'Start-Sleep -Seconds 5' Average time of 5 runs of 5 seconds is 5004.4389 milliseconds. NOTE: The Single Quotes. EXAMPLE .\Beginner_10_2011.ps1 -CMDLET 'Get-ChildItem -Path C:\Windows\System32 -Filter "*.dll"' Average time of 5 runs of 5 seconds is 150.44608 milliseconds. NOTE: The Single Quotes. EXAMPLE .\Beginner_10_2011.ps1 -Iterations 2 -CMDLET 'Get-ChildItem C:\Windows -Filter "*.txt" -Recurse' Average time of 2 runs of 5 seconds is 821.15165 milliseconds. NOTE: The Single Quotes.

  • Beginner1_2011.ps1 by Jason Stangroome 04 Apr 2011 09:11 AM UTC
    by 6 users

    Beginner Event 1
    3 Comments

  • New-ShareImageTool by Peter Rossi 18 Apr 2011 04:20 PM UTC
    by 3 users

    Advanced Event 8

    # Scripting Games 2011 - Advanced Event 8 # Written By: Peter Rossi # Date Written: 18th April 2011 # Overview: # This script will allow you to specify a certain folder of images to look through. You can then select each image and view a preview of it as well as # clicking through meta data to see what information is there. # Set the percentage of the original size that you wish to resize the photos to via the slider. # Click the prepare to share or prepare to share all buttons. Prepare to share will only output the selected file. Prepare to share all will process the entire folder. # External dependancies. This script uses exiftool.exe to extract and wipe metadata. This can be downloaded from http://www.sno.phy.queensu.ca/~phil/exiftool/exiftool-8.56.zip. # I have included a routine to automatically download the exiftool.exe and install it if you don't already have it.

  • out-tempfile.ps1 by mjolinor 21 Apr 2011 10:53 PM UTC
    by 3 users

    Advanced Event 10
    1 Comments

    Creates a temporary (.tmp) file in the system temp directory, and writes pipeline input to the file. Encoding and newlines can be specified by parameters, and will optionally open the file in Notepad after writing. Checks for interactive user environment before running Notepad, and prompts for verification before opening large files. Includes support for shouldprocess, provided debug and verbose output.

  • Measure-ScriptBlockAverageTime.ps1 by Frank ERBLAND 22 Apr 2011 02:05 AM UTC
    by 2 users

    Beginner Event 10
    2 Comments

    This script measure the average time a scriptblock takes to execute. It runs the scripblock n times and compute the average time with Measure-Command cmdlet. It display a formal message according the asked time unit. By default : It measures the scriptblock {Start-Sleep -Second 5}, 5 times, and shows average result in milliseconds (with 5 digits after decimal point). It also writes the result to the pipeline as an Microsoft.PowerShell.Commands.GenericMeasureInfo object. Possible intermediate results in verbose mode and a progress bar.

  • Test-AvgCmdTime.psm1 by Matt_G 22 Apr 2011 02:17 AM UTC
    by 2 users

    Beginner Event 10
    1 Comments

    Test the average time it takes to execute a command

  • GetFileInfo.psm1 by Frank ERBLAND 20 Apr 2011 01:35 AM UTC
    by 2 users

    Beginner Event 8
    1 Comments

    This function list all files in a folder and logs some informations in a unicode CSV file. Target folder [Path] and output file path [CsvPath] are MANDATORY parameters. The following informations are logged by default : Name, Size and Last write time, but other properties can be specified with parameter [Property]. The CSV file can be automatically opened with the switch [Open]. It launch the application associated with CSV.

  • Advanced8_2011 by Glenn Sizemore 15 Apr 2011 12:18 AM UTC
    by 3 users

    Advanced Event 8
    1 Comments

    PowerShell WinForm GUI that will convert, and sanitize images to be uploaded to the web. I chose to not use any external dependencies, as a result Script will run on any system windows XP SP3 and up. Script saves user settings to the registry. This challenge was a monster, as a result I recommend you run the script before reading the code as it will help ingest everything that is going on.

  • Set-SharedImages.ps1 by Matthew BETTON 17 Apr 2011 07:25 PM UTC
    by 2 users

    Advanced Event 8
    1 Comments

    Set-SharedImages.ps1 uses Windows Presentation Foundation (WPF) for displaying a user interface. This Graphical User Interface allows the user to : - Browse a directory for images (*.jpg, *.bmp, *.gif, *.png) ; - Displays Metadata informations for each image ; - Prepare one image or all images. For each image : - An output resized image is generated (640 x 480) ; - Metadata informations from original image are not kept ; - New image is saved as "SHARE_[].JPG", in selected destination folder. To work correctly this script needs : - "PowerShell Community Extension" Module : if not present in the modules folder, the script displays a message to inform the user where he can find it. The Pscx module is needed for resizing operations (Import-Bitmap, Resize-Bitmap and Export-Bitmap). - "Microsoft Windows Image Acquisition Library v2.0" library : if not present, the script automatically downloads it and install it, in the script current directory. The WIA library is needed for retrieving and displaying image file metadata. The script saves parameters (Source and destination folders) in the user's registry, under HKEY_CURRENT_USER\Software\ScriptingGames2011\ShareImages. You can use $DebugPreference variable in order to display DEBUG informations. Set $DebugPreference to "Continue" and the script will display DEBUG messages.

  • Measure-CommandTime.ps1 by Isaiah Jesch 21 Apr 2011 08:38 PM UTC
    by 2 users

    Beginner Event 10
    1 Comments

    This script uses Measure-Command to report on the time it takes Start-Sleep to work. Results are measured in total milliseconds and are reported as the average of 5 runs.

  • 2011sg_B10.ps1 by Dan 22 Apr 2011 12:48 AM UTC
    by 2 users

    Beginner Event 10
    1 Comments

  • Remove-ImageEXIF by Milo 20 Apr 2011 04:20 AM UTC
    by 2 users

    Advanced Event 8
    5 Comments

    The 2011 Scripting Games Advanced Event 8: Use PowerShell to Remove Metadata and Resize Images