Updated 10/15/2017 – Added -Override example
First off: WTF is CM_BUILD?
CM_BUILD is a PowerShell script that configures a “vanilla” Windows Server machine into having Configuration Manager Current Branch installed. This includes ADK, MDT, Server Roles and Features (WSUS, BITS, etc.), SQL Server, ConfigMgr itself, and a few goodies like Right-Click Tools, ConfigMgr Toolkit. The GitHub repo has a cute readme markdown page filled with overcaffeinated gibberish on how to use it. CM_SiteConfig is the “part 2” to cm_build, which configures ConfigMgr into a semi-functional site.
Short answer: https://github.com/Skatterbrainz/CM_Build
Okay, why CM_BUILD?
I don’t know. Why do we do anything? For the thrills? I could have taken up robbing banks, raising a crocodile farm, or breaking world records of swilling down cans of Four Loco while working on electrical equipment. But I chose the boring life. And while I’m bored, I hate clicking buttons repeatedly, so …
I got inspired by Johan and Mikael’s ConfigMgr Hydration Kits and Deployment Fundamentals Vol. 6 book examples, and Niall’s noob scripts, (I know it’s not actually called that, but it sounds cool to say “Niall’s noob scripts“), and after 45 cups of terrible coffee I said “I can shove all that into an XML file and call my JSON friends up and laugh hysterically at them, saying things like ‘You and your snotty little JSON drivel! Always mocking poor, starving little XML. Well, I’ll have you know I can still write XML, and probably even a little COBOL! So what do you think of that?! Hello? Hello? Did you just hang up on me?!! WTF!”
Anyhow…. Hold on, I need to get my dog outside before she has an accident….
okay, I’m back.
Why Invoke it over the Web?
There are several potential reasons for wanting to do this:
- I was really bored and it’s been raining all freakin day, and…
- It’s 3am and I can’t sleep, and…
- I saw this, and …
- I wanted to pull this off within Azure, using a VM extension, without having to import any actual files, and it would be cool to tie all this together with a runbook so I can send a text message “new lab configmgr p01“, to fire off a lab build in Azure and have it text me back “your stupid lab is ready, now leave me alone!” then I can forget it’s still running and it runs all my MSDN credits down to $0 until the next monthly cycle, and…
- I scrolled through Dan Bilzerian’s twitter feed just long enough to hate my boring life, and needed a distraction, and…
- It seemed like something cool to try
Time to put on a poker face and act serious now. The example below calls the cm_build.ps1 script from the GitHub master branch URL, converts it into a -ScriptBlock object, and passes in the -XmlFile parameter value using the Github Gist raw URL (you can make your own by copying the cm_build.xml into your own “secret” Gist, so you don’t openly share sensitive information to the whole world)
$ps1file = 'https://raw.githubusercontent.com/Skatterbrainz/CM_Build/master/cm_build.ps1' $xmlfile = '<your-gist-raw-url>' $script = Invoke-WebRequest $ps1file $scriptBlock = [ScriptBlock]::Create($script.Content) Invoke-Command -ScriptBlock $scriptBlock -ArgumentList @($xmlfile, $True, $True, $True)
But you can also invoke the interactive gridview menu using the -Override parameter, by simply appending one more $True into the -ArgumentList array.
Invoke-Command -ScriptBlock $scriptBlock -ArgumentList @($xmlfile, $True, $True, $True)
Then you get this budget-sized, corner-cutting, hack of a menu to choose from…
You may see a red warning about “Split-Path : Cannot bind argument to parameter ‘Path’ because it is null.” I’ll fix that soon. It only impacts the log output, but nobody reads log files anyway, right?
Anyhow, it’s 3:33 am, and I’m still typing, which is probably bad for my health, but if two people read this and it actually provide useful information one of you, mission accomplished. Actually, I know for a fact this is bad for my health. Regardless, I ran the above snippet (with a real URL in the $xmlfile assignment) in my Hyper-V duct-tape and chewing gum lab at home, and it worked like a charm. Now I can log into the server, open the ConfigMgr console and proceed with CM_SiteConfig, or apply real world tactics and break the ConfigMgr site entirely and start over.