Author Posts

October 25, 2016 at 10:51 am

A while ago (about a year?) there was a video posted of a talk given by Don Jones – at least I'm pretty sure it was him – on the subject of the best way to prompt for user input. I'd like to watch it again but can't find it.

I'm asking because I'm writing a new Create User script in Powershell to replace our >2,000 line long VB script but I'm unsure of the best way to gather info (new user's first name, last name, extension number, department, site, and so on) from the operator.

TIA!

October 25, 2016 at 12:05 pm

You can check his YouTube Channel. Before you ever get to a GUI, I would write and test the script\module that is going to be creating the users. Your only really filling in the blanks with variables. If you created a function New-TCUser (my mock company is TekCorp) and all you need to code in a GUI is

Import-Module TekCorpAD

$userParams = @{
    SamAccountName = $SamAccountName
    GivenName = $FirstName
    SurName = $LastName
    UserPrincipalName = "{0}.{1}@TekCorp.com" -f $FirstName, $LastName
}

$newUser = New-TCUser @userParams

Then you have something that could even create bulk users from a CSV. You provide the variables or appropriate properties and you have code that can be used any way you see fit.

As far as the GUI, you probably want to use a WPF or .NET form. If you use READ-HOST, you have to do more work to make sure someone entered the correct values, looping for mandatory, etc. in your workflow. With a GUI, you control the experience and items like Sites is a dropdown list. Sapien Powershell Studio is one of the best products to create forms with a WYSIWYG interface similar to Visual Studio and you could generate a form in a couple of minutes.

October 25, 2016 at 12:41 pm

I used MS orchestrator for this task in my organisation, i still use allot of PS scripting in the runbooks, but it has the benifits of encrypted passwords, choosing which DC to use and much more. we also put a front end on this using .net (not written by me as .net is more like japanese to me 🙂 )

this way may not work for all but for me i like the flexibility of the standard MS integration packs that do 90% of the work for you, all the varibles are held in the initialise data fields.

couple pics

http://i33.photobucket.com/albums/d92/markpriorgtst/Capture3.jpg

http://i33.photobucket.com/albums/d92/markpriorgtst/Capture2.jpg
http://i33.photobucket.com/albums/d92/markpriorgtst/Capture_4.jpg

http://i33.photobucket.com/albums/d92/markpriorgtst/Capture4.jpg

October 25, 2016 at 12:42 pm

Thank you.

I did look in his YouTube channel but couldn't see it there. I'm not sure it's a video he owns (he was up on stage, I think at a Microsoft convention, so someone else was recording it).

This script isn't for bulk creation, as we very rarely get more than one at a time.

A GUI sounds nice but isn't a requirement (beyond Out-GridView), and if it costs any money at all then it's a no-go anyway.

October 25, 2016 at 3:05 pm

mandatory params is the quickest way to ensure user input.

October 26, 2016 at 11:51 am

I found the video. It's not on his YouTube account, but is on the TechEd North America channel: Don Jones Best Practices talk at TechEd 2014

And as it turns out, the section I had in mind was more about output, rather than input (though he did also talk about input).