Orchestrator dabbling part 1

Recently, I have started looking more into System Center Orchestrator in my position to automate some basic tasks and possibly some more time consuming things over time.

The first couple things I came up with I thought could be helpful to others, so wanted to post up some information on the run books I have created, and what their purpose is and what they accomplish for me.

The first goal I wanted to accomplish was work out a way, that my test bed computers could have their OS refreshed on a weekly basis to keep them clean for future testing each week, without having to manually go in and kick off a Task Sequence as I was doing.

What I came up with a pretty basic run book that does the following, I will explain some parts of these steps later in the post.

Test-Bed-Scheduled-Reimage

  1. Check for specific time of the Day (in my case 10:00 AM)
  2. Check a Schedule (Every Sunday)
  3. Copy my Windows 10 Task Sequence
  4. Rename the Task Sequence (Name it with Date Appended as its a one time use TS)
  5. Deploy the Task Sequence to chosen collection.
  6. Send Email to me, so that I know it happened

The first 2 steps are quite basic (I only want the test bed to re-image on Sunday mornings, so I have it check for it being Sunday and check that its the time I want the re-image to happen at.)

For step 3, the reason I make a copy of a current task sequence for a few reasons

  • Having a custom Task Sequence allows for tracking and reporting of that specific one
  • As I want this to happen weekly, if I use the same task sequence from week to week, I would have to work around the Re-Run option of the task sequence.

The task sequence gets renamed, as by default when you copy a Task Sequence its given the same name as the original with just Package ID attached, I wanted a more standard name, and also needed to know the name going forward to be able to deploy it to the chosen collection with Orchestrator.

Then I use the Configmgr IP Connection from Orchestrator to deploy the new Task Sequence to my chosen collection.

Now to break down some of the steps and show how I am accomplishing the goal.

For the Copy TS step, I am using the following powershell script using the basic execute powershell script IP.

Import-Module “c:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1”
Set-Location “YOURSITECODE:\”
Copy-CMTaskSequence -Name “Windows 10 – Known Computer”
Sleep 30
$DayofMonth = (Get-Date).Day
$Year = (Get-Date).Year
$Month = (Get-Date).Month
$DateInfo = “$Month/$DayofMonth/$Year”
$TStoUse = Get-CMTaskSequence | Where-Object {$_.Name -like “*Known*FS*”} | Select-Object -ExpandProperty Name
$TS = Get-WmiObject -ComputerName FSUSCCM -Class SMS_TaskSequencePackage -Namespace root\sms\site_SITECODE | Where-Object {$_.Name -eq $TStoUse}
$TS.Name = “Windows-10-Test-Bed-$DateInfo”
$TS.Put()
Sleep 10

What happens in this script, is

  1. I import the ConfigMgr Powershell module
  2. Set location to the site code location to be able to run Scripts against Configuration Manger.
  3. Copy my current Windows 10 Task sequence
  4. Get the date and format the way I want it for the new TS Name.
  5. Use WMI to find a Task Sequence that has a name like “Known FS”, possibly not the best way, but this worked for me to be able to find the newly created TS from the copy.
  6. Rename the TS to Windows-10-Test-Bed-“The date format from earlier”

Next step is just a quick Run .Net script using Powershell also, to get the name into a variable that I can use in the Deploy Task Sequence activity.  With this, I also set the Published Data to be the final Variable $TestBedTS as this will be the name of the newly created and renamed Task Sequence for deployment.

$DayofMonth = (Get-Date).Day
$Year = (Get-Date).Year
$Month = (Get-Date).Month
$DateInfo = “$Month/$DayofMonth/$Year”
$TestBedTS = “Windows-10-Test-Bed-$DateInfo”

Next, I use the Deploy Task Sequence activity with the Name just being a name for my information, Task Sequence is published data from the previous step, which will tell it the name of the Task Sequence to use.  Collection is set to my test bed collection by name.  It is a required TS and the run behavior is to never rerun the program.

That is basically it, the other steps I have are one for it to send me an email stating the task sequence was created and deployed

Task Sequence Deployed: PUBLISHED DATA of the Task sequence name.

I then run a machine policy retrieval against the computers in the collection to attempt to jump start them knowing there is a new TS required for them.

Note this is probable not the best or cleanliest way to accomplish this, but gave me a reason to start dabbling in Orchestrator again, and it works for my purposes so far.  Any questions feel free to reach out, and I will assist as I can.

Thanks for reading

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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