SlideShare a Scribd company logo
Configuration Manager
Community Event
Switzerland 2014
Automating OSD and PostOSD Configuration with
Powershell and
Orchestrator
Triggering Runbooks and Webservices with Powershell in
Pre- and Post-Execution to conform with Asset Details in
the CMDB, allowing complex zero touch deployments
throughout the Desktop life cycle.
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Preparing the environment
Demo
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Demos
• The following demos contain plenty of powershell examples of
querying WMI, looking up datastores or SQL tables and
communicationg with Webservices and Orchestrator.
• The commands are included in slides after the demos.
Using Powershell to trigger local and
remote WMI queries and methods
Demo
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Using Powershell to access a datastore
Demo
Using Powershell to trigger web services
Demo
Using Powershell to add data to tables
Demo
Using Powershell to trigger Orchestrator
runbooks
Demo
Powershell Commands – local WMI
• $macAddress = (gwmi -Namespace rootcimv2 -Class
Win32_NetworkAdapterConfiguration -Filter "ipenabled =
'true'").MACAddress
• $smBIOSGUID = (gwmi -Namespace rootcimv2 -Class
Win32_ComputerSystemProduct).UUID
Powershell Commands – lookup xml
• [xml]$configScript = (New-Object
System.Net.WebClient).DownloadString("http://server:86/filena
me.xml")
• $dhcpServer = $configScript.Config.dhcpServer
Powershel Commands – write to SMSTS
• $tsenv = New-Object -ComObject
Microsoft.SMS.TSEnvironment
• $tsenv.Value("DHCPServer") = $dhcpServer
• $log = "$env:windirMaintenanceLogsPreExecutionHook.log"
• if(!(Test-Path $log)){New-Item -Path $log -ItemType File Force}
• "TS Variables:" | Out-File $log -Append
• $tsenv.GetVariables() | %{"$_ = $($tsenv.Value($_))" | Out-File
$log -Append}
Powershell Commands – storing
Credentials
•

#Enter credential and save to file

• $key = (2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43,6,6,6,6,6,6,31,33,60,23)
• $cred = Get-Credential
• $pwFile = New-Item -Path "c:WindowsTemp" -Name "pwFile.txt"-ItemType File -Force
• $userFile = New-Item -Path "c:WindowsTemp" -Name "userFile.txt"-ItemType File -Force

• $cred.UserName | Set-Content -Path $userFile
• $cred.Password | ConvertFrom-SecureString -Key $key | Set-Content -Path $pwFile
• #Retrieve credentials from text file
• $userFile = "userfile.txt"
• $pwFile = "pwfile.txt"
• $user = Get-Content $userFile
• $pw = Get-Content $pwFile
• $password = $pw | ConvertTo-SecureString -Key $key

• $credential = New-Object System.Management.Automation.PsCredential($user,$password)
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Powershell commands – call webservice
# Create a webservice connection
try{
$svc = New-WebServiceProxy –Uri 'http://aclabcm01:88/ConfigMgrWebService.asmx'
}catch{
$err = $_
}
if($err -ne $null){
"$err - exiting" | Out-File $log -Append
exit
}
Get methods: $svc | gm –MemberType Method
Get method parameters: $svc | gm –MemberType Method –Name GetComputerRessourceID |
select Definition
Pete Zerger’s blog
• http://www.systemcentercentral.com/how-to-initiate-a-runbookfrom-powershell-and-orchestrator-web-service-the-easy-way/
• Leverage PowerPivot in Excel to get the Runbook and Runbook
Parameter GUIDs
Use Orchestrator to add computers
• Set up a database to store requests
• Write to the database via Powershell in the Pre-Execution Hook

• Schedule Runbook to read from the database every 5 – 10
minutes
• Use either an Integration Pack or a Powershell script to
programatically add the computers
• Update the status in the database
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
What can we automate after OSD?
• Configuration post-OSD of a computer is by design carried out by
ConfigMgr
• What cannot be accomplished in the TS can be deployed as configuration
settings in a baseline, or installed as an application
• Triggering post-install tasks really only affects VDI situations where the
ConfigMgr client may be removed after staging
• SMSTSPostAction:

• C:Windowsccmsetupccmsetup.exe /uninstall
• Only one command possible
• postConfig.ps1
• Wrap commands like ccmsetup uninstall in a script

• Other actions
•
•
•
•
•

Prepare disk for Hyper-V
Citrix PVS prepare machine for P2V
XenDesktop prepare disk as master
Other third party virtualisation products
Remove from domain
Questions & Answers
Thank you!
Kontakt aufnehme
• www.configmgr.ch
• andrewdcraig.wordpress.com
• Twitter: @mracraig

More Related Content

PDF
Configuration Management in Ansible
KEY
Express Presentation
PDF
Service worker: discover the next web game changer
PDF
Future Decoded - Node.js per sviluppatori .NET
PPTX
Coolblue - Behind the Scenes Continuous Integration & Deployment
PDF
Getting Started with Ansible
PDF
Getting Started with Couchbase Ruby
PPTX
Ansible presentation
Configuration Management in Ansible
Express Presentation
Service worker: discover the next web game changer
Future Decoded - Node.js per sviluppatori .NET
Coolblue - Behind the Scenes Continuous Integration & Deployment
Getting Started with Ansible
Getting Started with Couchbase Ruby
Ansible presentation

What's hot (20)

PDF
#OktoCampus - Workshop : An introduction to Ansible
ODP
ansible why ?
PPTX
Drupal cambs ansible for drupal april 2015
PPTX
Building Web Apps with Express
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
PPT
Dance for the puppet master: G6 Tech Talk
PPTX
Introduction to Ansible
PPTX
The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017
PDF
Deploying Rails Applications with Capistrano
PPTX
Automating with Ansible
PDF
Ansible Introduction - Ansible Brno #1 - David Karban
PPTX
Using Ansible Dynamic Inventory with Amazon EC2
PDF
Building Distributed System with Celery on Docker Swarm
PDF
Ansible roles done right
PPTX
Ansible presentation
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
PDF
Ansible - Introduction
PDF
Ansible Meetup Hamburg / Quickstart
PDF
Network Automation: Ansible 102
PPTX
Creating Reusable Puppet Profiles
#OktoCampus - Workshop : An introduction to Ansible
ansible why ?
Drupal cambs ansible for drupal april 2015
Building Web Apps with Express
Ansible is the simplest way to automate. MoldCamp, 2015
Dance for the puppet master: G6 Tech Talk
Introduction to Ansible
The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017
Deploying Rails Applications with Capistrano
Automating with Ansible
Ansible Introduction - Ansible Brno #1 - David Karban
Using Ansible Dynamic Inventory with Amazon EC2
Building Distributed System with Celery on Docker Swarm
Ansible roles done right
Ansible presentation
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Ansible - Introduction
Ansible Meetup Hamburg / Quickstart
Network Automation: Ansible 102
Creating Reusable Puppet Profiles
Ad

Similar to Automating OSD and Post-OSD Configuration with Powershell and Orchestrator (20)

PPTX
Fredrik Knalstad - 10 ways to trigger orchestrator runbooks in the it jungle
PPTX
Fredrik knalstad 10 ways to trigger orchestrator runbooks in the it jungle
PPTX
10 ways to trigger runbooks from Orchestrator
PPTX
SCU Asia System Center: Beyond orchestrator
PDF
PowerShell Tipps & Tricks im Configuration Manager
PPTX
ECMDAY2015 - Kaido Jarvemets - Managing Configuration Manager with PowerShell
PPSX
Sunil phani's take on windows powershell
PPT
PowerShell v4 Desired State Configuration
PPTX
Troubleshooting a XenDesktop Environment using the PowerShell SDK
PPTX
Introduction to Desired State Configuration (DSC)
PDF
VMworld Europe 2014: Taking Reporting and Command Line Automation to the Next...
DOCX
Application Catalog and Approval Runbooks Sample
PPTX
Windows Remote Management - EN
PDF
Aws meetup ssm
PDF
SCORCH: Tying it All Together
PDF
Windows PowerShell V2 の新機能
PPTX
Powershell Tech Ed2009
PPSX
Automating Windows Server 2008 R2 Administration with Windows PowerShell
PPTX
Configuration management comes to Windows
PPTX
Opmanager Workshop - Middle East
Fredrik Knalstad - 10 ways to trigger orchestrator runbooks in the it jungle
Fredrik knalstad 10 ways to trigger orchestrator runbooks in the it jungle
10 ways to trigger runbooks from Orchestrator
SCU Asia System Center: Beyond orchestrator
PowerShell Tipps & Tricks im Configuration Manager
ECMDAY2015 - Kaido Jarvemets - Managing Configuration Manager with PowerShell
Sunil phani's take on windows powershell
PowerShell v4 Desired State Configuration
Troubleshooting a XenDesktop Environment using the PowerShell SDK
Introduction to Desired State Configuration (DSC)
VMworld Europe 2014: Taking Reporting and Command Line Automation to the Next...
Application Catalog and Approval Runbooks Sample
Windows Remote Management - EN
Aws meetup ssm
SCORCH: Tying it All Together
Windows PowerShell V2 の新機能
Powershell Tech Ed2009
Automating Windows Server 2008 R2 Administration with Windows PowerShell
Configuration management comes to Windows
Opmanager Workshop - Middle East
Ad

More from Digicomp Academy AG (20)

PDF
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
PDF
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
PPTX
Innovation durch kollaboration gennex 2018
PDF
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
PDF
Roger basler meetup_21082018_work-smarter-not-harder_handout
PDF
Xing expertendialog zu nudge unit x
PDF
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
PDF
IPv6 Security Talk mit Joe Klein
PDF
Agiles Management - Wie geht das?
PPTX
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
PDF
Querdenken mit Kreativitätsmethoden – XING Expertendialog
PDF
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
PDF
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
PDF
UX – Schlüssel zum Erfolg im Digital Business
PDF
Minenfeld IPv6
PDF
Was ist design thinking
PDF
Die IPv6 Journey der ETH Zürich
PDF
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
PDF
General data protection regulation-slides
PDF
Möglichkeiten der Online-Werbung - Referat von Matteo Schürch
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
Innovation durch kollaboration gennex 2018
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
Roger basler meetup_21082018_work-smarter-not-harder_handout
Xing expertendialog zu nudge unit x
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
IPv6 Security Talk mit Joe Klein
Agiles Management - Wie geht das?
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
Querdenken mit Kreativitätsmethoden – XING Expertendialog
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
UX – Schlüssel zum Erfolg im Digital Business
Minenfeld IPv6
Was ist design thinking
Die IPv6 Journey der ETH Zürich
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
General data protection regulation-slides
Möglichkeiten der Online-Werbung - Referat von Matteo Schürch

Recently uploaded (20)

PPTX
ICG2025_ICG 6th steering committee 30-8-24.pptx
PPTX
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
PPTX
Belch_12e_PPT_Ch18_Accessible_university.pptx
PDF
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
PDF
20250805_A. Stotz All Weather Strategy - Performance review July 2025.pdf
PDF
Ôn tập tiếng anh trong kinh doanh nâng cao
PPTX
New Microsoft PowerPoint Presentation - Copy.pptx
DOCX
unit 1 COST ACCOUNTING AND COST SHEET
PPTX
5 Stages of group development guide.pptx
PPTX
HR Introduction Slide (1).pptx on hr intro
PPTX
Amazon (Business Studies) management studies
PPTX
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
PDF
Unit 1 Cost Accounting - Cost sheet
PDF
Laughter Yoga Basic Learning Workshop Manual
PPTX
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
PDF
A Brief Introduction About Julia Allison
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PPTX
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PPT
Data mining for business intelligence ch04 sharda
ICG2025_ICG 6th steering committee 30-8-24.pptx
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
Belch_12e_PPT_Ch18_Accessible_university.pptx
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
20250805_A. Stotz All Weather Strategy - Performance review July 2025.pdf
Ôn tập tiếng anh trong kinh doanh nâng cao
New Microsoft PowerPoint Presentation - Copy.pptx
unit 1 COST ACCOUNTING AND COST SHEET
5 Stages of group development guide.pptx
HR Introduction Slide (1).pptx on hr intro
Amazon (Business Studies) management studies
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
Unit 1 Cost Accounting - Cost sheet
Laughter Yoga Basic Learning Workshop Manual
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
A Brief Introduction About Julia Allison
Power and position in leadershipDOC-20250808-WA0011..pdf
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
Data mining for business intelligence ch04 sharda

Automating OSD and Post-OSD Configuration with Powershell and Orchestrator

  • 2. Automating OSD and PostOSD Configuration with Powershell and Orchestrator Triggering Runbooks and Webservices with Powershell in Pre- and Post-Execution to conform with Asset Details in the CMDB, allowing complex zero touch deployments throughout the Desktop life cycle.
  • 7. Demos • The following demos contain plenty of powershell examples of querying WMI, looking up datastores or SQL tables and communicationg with Webservices and Orchestrator. • The commands are included in slides after the demos.
  • 8. Using Powershell to trigger local and remote WMI queries and methods Demo
  • 10. Using Powershell to access a datastore Demo
  • 11. Using Powershell to trigger web services Demo
  • 12. Using Powershell to add data to tables Demo
  • 13. Using Powershell to trigger Orchestrator runbooks Demo
  • 14. Powershell Commands – local WMI • $macAddress = (gwmi -Namespace rootcimv2 -Class Win32_NetworkAdapterConfiguration -Filter "ipenabled = 'true'").MACAddress • $smBIOSGUID = (gwmi -Namespace rootcimv2 -Class Win32_ComputerSystemProduct).UUID
  • 15. Powershell Commands – lookup xml • [xml]$configScript = (New-Object System.Net.WebClient).DownloadString("http://server:86/filena me.xml") • $dhcpServer = $configScript.Config.dhcpServer
  • 16. Powershel Commands – write to SMSTS • $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment • $tsenv.Value("DHCPServer") = $dhcpServer • $log = "$env:windirMaintenanceLogsPreExecutionHook.log" • if(!(Test-Path $log)){New-Item -Path $log -ItemType File Force} • "TS Variables:" | Out-File $log -Append • $tsenv.GetVariables() | %{"$_ = $($tsenv.Value($_))" | Out-File $log -Append}
  • 17. Powershell Commands – storing Credentials • #Enter credential and save to file • $key = (2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43,6,6,6,6,6,6,31,33,60,23) • $cred = Get-Credential • $pwFile = New-Item -Path "c:WindowsTemp" -Name "pwFile.txt"-ItemType File -Force • $userFile = New-Item -Path "c:WindowsTemp" -Name "userFile.txt"-ItemType File -Force • $cred.UserName | Set-Content -Path $userFile • $cred.Password | ConvertFrom-SecureString -Key $key | Set-Content -Path $pwFile • #Retrieve credentials from text file • $userFile = "userfile.txt" • $pwFile = "pwfile.txt" • $user = Get-Content $userFile • $pw = Get-Content $pwFile • $password = $pw | ConvertTo-SecureString -Key $key • $credential = New-Object System.Management.Automation.PsCredential($user,$password)
  • 20. Powershell commands – call webservice # Create a webservice connection try{ $svc = New-WebServiceProxy –Uri 'http://aclabcm01:88/ConfigMgrWebService.asmx' }catch{ $err = $_ } if($err -ne $null){ "$err - exiting" | Out-File $log -Append exit } Get methods: $svc | gm –MemberType Method Get method parameters: $svc | gm –MemberType Method –Name GetComputerRessourceID | select Definition
  • 21. Pete Zerger’s blog • http://www.systemcentercentral.com/how-to-initiate-a-runbookfrom-powershell-and-orchestrator-web-service-the-easy-way/ • Leverage PowerPivot in Excel to get the Runbook and Runbook Parameter GUIDs
  • 22. Use Orchestrator to add computers • Set up a database to store requests • Write to the database via Powershell in the Pre-Execution Hook • Schedule Runbook to read from the database every 5 – 10 minutes • Use either an Integration Pack or a Powershell script to programatically add the computers • Update the status in the database
  • 25. What can we automate after OSD? • Configuration post-OSD of a computer is by design carried out by ConfigMgr • What cannot be accomplished in the TS can be deployed as configuration settings in a baseline, or installed as an application • Triggering post-install tasks really only affects VDI situations where the ConfigMgr client may be removed after staging • SMSTSPostAction: • C:Windowsccmsetupccmsetup.exe /uninstall • Only one command possible • postConfig.ps1 • Wrap commands like ccmsetup uninstall in a script • Other actions • • • • • Prepare disk for Hyper-V Citrix PVS prepare machine for P2V XenDesktop prepare disk as master Other third party virtualisation products Remove from domain
  • 27. Kontakt aufnehme • www.configmgr.ch • andrewdcraig.wordpress.com • Twitter: @mracraig