In addition to native integration with Chef and Puppet, vCommander® may be integrated with Microsoft System Center Configuration Manager using the solution described in this article. This solution uses PS-Remoting to communicate with the SCCM server, but there are other methods you could alternatively employ -- for example installing the client on the vCommander server.
Requirements
- vCommander 5.6.4 or later
- PowerShell v4 installed on vCommander application server
- Encrypted credentials (to encrypt domain admin credentials)
- Embotics REST API PowerShell libraries
- Embotics SCCM Scripts
Creating the Completion Workflow
This solution requires that the SCCM scripts be available on the vCommander server, where they can be called by the workflow.
- Download the SCCM scripts package to the vCommander application server.
- Extract the scripts to C:\Scripts.
Note that this example includes retrieving the value for a list-type custom attribute called Install AV as an example of controlling the installation options. When you implement the solution, you will customize to your particular needs.
Next, create a Completion Workflow which uses these files in script steps.
- Browse to Configuration > Service Request Configuration and switch to the Completion Workflow tab.
- Click Add.
- Provide a Name and choose to Apply this workflow: after a VM is deployed. Click Next.
- Click Add > Wait for Event and configure the step as follows:
Step Name: Guest OS Completion
Step Execution: Always execute
Wait For: Guest OS customization to complete
Wait Time: 600 seconds
Wait Time Exceeded: Mark workflow step as failed: do not proceed Click Add > Wait for Event and configure the step as follows:
Step Name: IP/DNS
Step Execution: Always execute
Wait For: Service to obtain IP address and DNS name
Wait Time: 300 seconds
Wait Time Exceeded: Mark workflow step as failed: do not proceedClick Add > Guest OS > Run Program and configure the step as follows:
Step Name: Create temp Dir.
Step Execution: Always Execute
Timeout: 300 seconds
Credentials: Choose credentials with admin rights on the deployed VMs. Click Add Credentials to add a new user to the vCommander credentials library.
Program Output: Capture program output as comment
When Program Fails: Mark Workflow step as failed: do not proceed
Command Line:c:\windows\system32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -command "& { New-Item -Path c:\temp -ItemType directory}"
Click Add > Guest OS > Create File and configure the step as follows:
Contents:
Step Name: Create File
Step Execution: Always execute
When Step Fails: Mark workflow step as failed: do not proceed
Credentials: Choose credentials with admin rights on the deployed VMs. Click Add Credentials to add a new user to the vCommander credentials library.Copy-Item \\svrad01.embotics.com\SoftwareDeployment\ccmsetup.cab -Destination c:\temp Copy-Item \\svrad01.embotics.com\SoftwareDeployment\ccmsetup.exe -Destination c:\temp Copy-Item \\svrad01.embotics.com\SoftwareDeployment\Installsccm.bat -Destination c:\temp Copy-Item \\svrad01.embotics.com\SoftwareDeployment\ccmsetup.msi -Destination c:\temp Write-Host 'copy SCCM Agent installer complete!' Copy-Item \\svrad01.embotics.com\SoftwareDeployment\scepinstall.exe -Destination c:\temp Write-Host 'copy AV installer complete!' Copy-Item \\svrad01.embotics.com\SoftwareDeployment\AVG.exe -Destination c:\temp Write-Host 'copy AVG installer complete!'
Destination: c:\temp\copyfiles.ps1
Overwrite: enabled
Click Add > Guest OS > Run Program and configure the step as follows:
Step Name: Run Download Script
Step Execution: Always execute
Timeout: 600 seconds
Credentials: Choose credentials with admin rights on the deployed VMs. Click Add Credentials to add a new user to the vCommander credentials library.
Program Output: Capture program output as comment
When Program Fails: Mark workflow step as failed: do not proceed
Command Line:c:\windows\system32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -command "& { c:\temp\copyfiles.ps1}"
Click Add > Guest OS > Run Program and configure the step as follows:
Step Name: Install SCCM client
Step Execution: Always execute
Timeout: 300 seconds
Credentials: Choose credentials with admin on the deployed VMs. Click Add Credentials to add a new user to the vCommander credentials library.
Program Output: Proceed to next workflow step
Command Line:c:\temp\ccmsetup.exe /forceinstall /Service /mp:fqdn.your_server.com /SMSSITECODE=YOW SMSSLP= /mp:fqdn.your_server.com SMSMP= /mp:fqdn.your_server.com SMSCACHESIZE=5240 DISABLESITEOPT=TRUE
Click Add > Wait for Event and configure the step as follows:
Step Name: Wait for SCCM Client
Step Execution: Always execute
Wait For: Time to elapse
Wait Time: 300 secondsClick Add > Execute Script and configure the step as follows:
Step Name: Add VM to collection
Step Execution: Always execute
Timeout: 300 seconds
Script Output: Capture script output as comment
When Step Fails: Mark workflow step as failed: do not proceed
Command Line:c:\windows\system32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -command "& { c:\scripts\SCCMDirectAssignment.ps1 -SccmServer ‘ /mp:fqdn.your_server.com' -SiteCode 'YOW' -ADCredFile 'c:\scripts\credentials.xml' -ComputerName '#{target.dnsName}' -CollectionName 'demo collection'}"
Click Add > Guest OS > Run Program and configure the step as follows:
Step Name: Install AV if selected
Step Execution: Execute when conditions are met
Command Line:#{target.settings.customAttribute['Install AV']} -eq Yes
Timeout: 200 seconds
Credentials: Choose credentials with admin on the deployed VMs. Click Add Credentials to add a new user to the vCommander credentials library.
Program Output: Capture program output as comment
When Program Fails: Proceed to next workflow stepCommand Line:
c:\windows\system32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -command "&{ Start-Process -FilePath “c:\temp\scepinstall.exe" -ArgumentList “/s /q”
Click Add > Execute Script and configure the step as follows:
Step Name: Update Collection
Step Execution: Always Execute
Timeout: 300 seconds
Script Output: Capture script output as comment
When Script Fails: Mark workflow step as failed: do not proceed
Command Line:c:\windows\system32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -command "& { c:\scripts\UpdateCollectionMembership_demo.ps1}"
Complete the wizard as appropriate and click Finish.