ConfigMgr Preflight with XAML and PowerShell Part 2

Its been a little while since I’ve had chance to sit down and think up a post. The end of September was the deadline for a big project I’ve been working on, so I was pretty busy trying to make sure things were done. Things have slightly settled down now, so I’ve had more time to play with personal projects and improve my ConfigMgr app.

A separate idea I had for PowerShell and ConfigMgr, was to create some kind of portal for 1st line technicians to add machines for Operating System builds. The idea being they wouldnt have to go into the console to import computer information. My initial thoughts were to use a html frontend, which I would host on a tiny web server and then have PowerShell do my script work. After digging into this I figured it would require a proper web app to do something like that, using server code.

So instead, I decided to just extend my preflight app to provide this functionality. To do this, I needed to set the task sequence variable for a device’s Computer Name using a .NET object only present in a WinPE image built with ConfigMgr:

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment

Then the rest was really easy, using this TechNet reference –

I found the variable I needed, and then just set the user input for Computer Name field:

$tsenv.Value(OSDComputerName) = $computerNameInput.Text

I tried to be a bit clever with my placement with this, as I wanted to ensure that the user had actually put something in the box before continuing. Moving forward, I think I’ll look into making sure the input is what I expect it to be using a regular expression (regex).

My updated code is on GitHub, here, feel free to have a look and see if you’d find it useful :). Also feel free to leave a comment if you have a question at all.

ConfigMgr Preflight with XAML and PowerShell Part 2

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 )

Google photo

You are commenting using your Google 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