Agenda Orchestrator - Components Orchestrator – For the ConfigMgr Admin.
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
-
Upload
digicomp-academy-ag -
Category
Business
-
view
682 -
download
3
Transcript of Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
![Page 1: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/1.jpg)
Configuration Manager Community Event Switzerland 2014
![Page 2: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/2.jpg)
Automating OSD and Post-OSD Configuration with Powershell and OrchestratorTriggering 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.
![Page 3: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/3.jpg)
![Page 4: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/4.jpg)
Demo
Preparing the environment
![Page 5: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/5.jpg)
![Page 6: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/6.jpg)
![Page 7: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/7.jpg)
Demos
• The following demos contain plenty of powershell examples ofquerying WMI, looking up datastores or SQL tables andcommunicationg with Webservices and Orchestrator.
• The commands are included in slides after the demos.
![Page 8: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/8.jpg)
Demo
Using Powershell to trigger local and remote WMI queries and methods
![Page 9: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/9.jpg)
![Page 10: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/10.jpg)
Demo
Using Powershell to access a datastore
![Page 11: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/11.jpg)
Demo
Using Powershell to trigger web services
![Page 12: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/12.jpg)
Demo
Using Powershell to add data to tables
![Page 13: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/13.jpg)
Demo
Using Powershell to trigger Orchestrator runbooks
![Page 14: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/14.jpg)
Powershell Commands – local WMI
• $macAddress = (gwmi -Namespace root\cimv2 -Class Win32_NetworkAdapterConfiguration -Filter "ipenabled = 'true'").MACAddress
• $smBIOSGUID = (gwmi -Namespace root\cimv2 -Class Win32_ComputerSystemProduct).UUID
![Page 15: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/15.jpg)
Powershell Commands – lookup xml
• [xml]$configScript = (New-ObjectSystem.Net.WebClient).DownloadString("http://server:86/filename.xml")
• $dhcpServer = $configScript.Config.dhcpServer
![Page 16: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/16.jpg)
Powershel Commands – write to SMSTS
• $tsenv = New-Object -ComObjectMicrosoft.SMS.TSEnvironment
• $tsenv.Value("DHCPServer") = $dhcpServer
• $log = "$env:windir\Maintenance\Logs\PreExecutionHook.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}
![Page 17: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/17.jpg)
Powershell Commands – storingCredentials• #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:\Windows\Temp" -Name "pwFile.txt"-ItemType File -Force
• $userFile = New-Item -Path "c:\Windows\Temp" -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)
![Page 18: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/18.jpg)
![Page 19: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/19.jpg)
![Page 20: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/20.jpg)
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
![Page 21: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/21.jpg)
Pete Zerger’s blog
• http://www.systemcentercentral.com/how-to-initiate-a-runbook-from-powershell-and-orchestrator-web-service-the-easy-way/
• Leverage PowerPivot in Excel to get the Runbook and RunbookParameter GUIDs
![Page 22: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/22.jpg)
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 toprogramatically add the computers
• Update the status in the database
![Page 23: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/23.jpg)
![Page 24: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/24.jpg)
![Page 25: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/25.jpg)
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:\Windows\ccmsetup\ccmsetup.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
![Page 26: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/26.jpg)
Questions & AnswersThank you!
![Page 27: Automating OSD and Post-OSD Configuration with Powershell and Orchestrator](https://reader033.fdocuments.us/reader033/viewer/2022050809/55d55f6bbb61eb37038b45b6/html5/thumbnails/27.jpg)
Kontakt aufnehme
• www.configmgr.ch
• andrewdcraig.wordpress.com
• Twitter: @mracraig