PowerShell OSD Frontend with Windows Forms

Version 2.0 is out!

 

Recently we upgraded to System Center Configuration Manager 2012 SP1  and I am responsible for all of our Operating System Deployment (OSD) pieces. We were using a nice little HTA with ConfigMgr 2007 but with PowerShell 3.0 support in WinPE 4.0 I just couldn’t pass up writing my own frontend!

I present the PowerShell OSD FrontEnd!

osdfrontend_mainscreen

Capabilities:

  • Prompts for authentication to your domain
  • Displays basic computer information such as Make, Model, NIC, etc
  • Prompts for computer name, with a few samples listed
  • Default computer name is WK and the machines serialnumber
  • For VMWare virtual machines, computer name is VM and the authenticated user
  • Scans your site server for existing device records
  • Utility to format disk
  • Utility to delete ConfigMgr records
  • Utility to specify source computer for data migration

Usage:

  • When you boot into WinPE, you first get prompted to authenticate, note that you do not need to type your domain suffix

osdfrontend_authentication

  • Once you are on the main screen you can see the basic information about the machine you are booted into
  • You may specify the computername you want the machine to have, and there are a few samples that you are welcome to modify as needed
    • The samples have a prefix and the serial number
  • The username that you have authenticated as is listed as the Imaged By: user
  • The information on the right shows any devices for the machine you are booted into on the specified ConfigMgr site server. The script searches for the following:
    • Computername
    • MAC address
    • SMBIOSGUID/UUID

Delete ConfigMgr Record

  • This is primarily intended for task sequences deployed to Unknown Devices

osdfrontend_deleterecord

Format Disk Utility

  • Currently using DISKPART
  • DISKPART
  • select disk x, where x is the drive you choose from the dropdown
  • clean
  • create partition primary
  • assign letter=c
  • format fs=ntfs quick
  • active

osdfrontend_format1osdfrontend_format2

Data Migration

  • Currently under construction
  • Specifies a computer name to migrate data and/or applications from

osdfrontend_datamigration

Customizing for your organization

There are a handful of things you need to do use this script in your organization, I have stripped out all environment specific settings so you will need to edit the following:

  • Create or edit the existing OSDLogo.png in the root of the script directory
    • 322×59 pixels recommended
  • Edit specific lines in frontend.ps1
    • Line 18 – Title
    • Line 19 – Icon (optional)
    • Line 42 – Add your domain (does not need to be the FQDN)
    • Line 71 – Logo image
    • Line 129 – Sample computername
    • Line 136 – Sample computername
    • Line 143 – Sample computername
    • Line 150 – Sample computername
    • Line 353 – Add your ConfigMgr site server
    • Line 354 – Add your ConfigMgr site code
    • Line 369 – AD account to query site server via WMI, DOMAIN\username
    • Line 370 – AD account password

Boot image requirements

I am using this frontend as a pre-start command on all my boot images, I need this capability for the authentication before the task sequence wizard is displayed and it also acts as a nice front end for our operational teams for an almost zero-touch experience.

Just run the following command to kick it off:

Your source location can actually be a network share, it does not have to be a ConfigMgr package or application, which provides some nice flexibility. Just point to the same directory as frontend.ps1.

Task Sequence requirements

In order to utilize the computername, username, and data migration functionality you need add just a few steps into your task sequence.

The script stores all variables in text files in its own root, on a WinPE 4.0 boot disc this is the following location:

x:\sms\pkg\sms10000

The text files in that location are below:

computername.txt – Computername specified by user

username.txt – User authenticated to the frontend

sourcecomputer.txt – Computer specified in the Data Migration utility

In order to translate these text files into task sequence variables I was never able to get the Run Command Line step to work properly so I created a package with different powershell scripts for each variable.

The content of each is below:

Finally I have a step to do some branding in the registry using the above variables! I use a simply Run Command Line:

Future Customizations

This has been a fun little project for me, and I am continuing to develop it. Feel free to comment or contact me with any suggestions, so far I have a few requests listed below.

  • Functionality to stage the machine in AD, choice for OU
  • Integration with OSDAppTree from Jason Sandys.
  • Printer installation/migration
  • Prompts for user for User Device Affinity
  • Change the format disk utility to use the PowerShell storage cmdlets
  • Change AD authentication to only allow users of a certain AD group

Download files: frontend.zip

Full script:

 

32 thoughts on “PowerShell OSD Frontend with Windows Forms

  1. Great utility, if you start a github project I’d love to collaborate with you. This is a nice bit of work and I love the flex it adds into OSD. Thank you for sharing!

    • Thanks Jason, I honestly have never looked at any open source sites and this is truly my first online publication. If it ever ends up at Github, Sourceforge, or the like I will definitely let you know.

  2. Rik

    Very Nice! Trying it out right now.
    I noticed that you didn’t mention that you need to add Powershell as an optional component to the boot images where you want to use this frontend as a prestart command.
    I would like to add a field to enter a location and desired language; so i can use this in the OSD TS to select the proper language. How could i do that? Add another “New-Object System.Windows.Forms.Label” ?

    • Thanks Rik. On my next round of updates I will add the explicit requirements needed to run everything.

      To add another option you nailed it. Another Label and TextBox. Also note the ClickButton at the bottom of the script, this is where it takes the input and stores it in a .txt file to be imported as a TS variable in your task sequence. Good luck!

  3. Shawn

    I just wanted to give a thanks for sharing. Working like a champ with some minor tweaking and tuning. I was able to implement some actions in our environment that I have been trying to figure out a good way of doing.

    • Glad to hear it! I am actually about to release 2.0 this month some time. Some of the new features include tabs, UDA, and a nice little CMTrace.exe button.

  4. Jon

    Could you run it from inside the task sequence as a cmd line? I have two different TS one for workstation and one for servers. If I add it to the boot image both will get it when I might want different menus for each. thanks

    • You should be able to, just note this is designed for WinPE not inside the OS. Its all PowerShell and Windows Forms so as long as you have that support in your boot image it should work!

      • Jon

        I got it to work. I am using a .net frontend and had to use the serviceui.exe to launch it from the TS. If I just ran the .ext menu from run cmd line it would launch cause I could see the process in taskmgr but it wasn’t displaying the menu.

  5. […] have made fairly constant updates to my original OSD Frontend and I found it time to share among the community again. I had hoped to make this available a few […]

  6. Ultra9

    Is there way to add ASSETTAG instead serialnumber.

    • Definitely Ultra9, that is just a change to the text on line 110.

  7. Ratsour

    Looks great and finally I found something on which I was working from a long time.
    Actually I am a beginner as OSD point of view, so I have many queries.
    First I want to know how to implement it inside the task sequence(Not for WINPE)?
    Second alternative of PowerShell means DOS commands ?
    Please provide if you have any detailed document regarding the frontends, how they work in TS.

    • Ratsour, the FrontEnd can be ran inside the task sequence but there are a few issues running inside the OS. I have not fully tested all functionality in the OS, so use at your own risk.

      Most techs will use VBScript instead of DOS/Batch commands, but PowerShell is the scripting language to use. Its the most efficient and powerful to boot.

      FrontEnds are really about providing your own input and manually gathering the data you need in the task sequence. You don’t always need one, and you don’t always need all the functionality that others have written. You need to evaluate what your own needs are and go from there.

  8. […] All applications used here are portable executables capable of running under both amd64 and x86 architecture. The DiskPart GUI Tool is a scripted utility, and the idea for this GUI tool I’ve found by reading about a utility to format disk, posted by Daniel Ratliff – http://www.potentengineer.com/powershell-osd-frontend-with-windows-forms/. […]

  9. Chad GIbson

    IS there anyway to change this script to make it where it will do the AD authentication and if it is correct then run a bat file and if not exit?? Don’t really need all the other stuff but really new to power shell scripting.
    Thanks
    Chad

  10. Nate B

    If this PS front end had UI++ integration, it would be a more complete front end! Here’s my vote for UI_++ collaboration 🙂

  11. Ovi

    Any way to edit this so can work exactly the same with a standalone media? I want to just be able to use USB drive to hold packages and not have to depend on distribution point.

    • StandAlone media support is added in v3.0! Been working on it for the past couple months, so it’s coming soon! Just a FYI, any packages you put in your task sequences are references locally in StandAlone media. Are you looking more for a repository where a tech could choose what apps he wants to install?

  12. sundeep

    Hi Daniel
    Trying to download the version 2. But I get a page not found error on the page
    Also are you releasing version 3 soon

    Thanks

  13. Bryan

    In the compinfo function you have:


    $model = (get-ciminstance win32_computersystemproduct).version
    $modelnumber = (Get-CimInstance -classname win32_computersystem).model

    I believe it should be


    $model = (get-ciminstance win32_computersystemproduct).model
    $modelnumber = (Get-CimInstance -classname win32_computersystem).version
    </code

    • Thanks Bryan, good catch. I will fix this in version 3.0.

  14. Michael

    Any newer version?

  15. Dries

    Awesome tool … waiting for version 3 🙂

  16. Robert

    Hello, the link at the top that says 2.0 is out gives an internal server error. Did you ever release 3.0? Thanks!

    • Thanks Robert, the link has been updated. 3.0 has been close for a while, but I have had some trouble getting High DPI to work. Still chugging away at it!

      • Jarko

        Really interested to have a look at your Version 3.0! Hope you get the High DPI sorted.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">