SCCM PowerCLI Silent deployment script

A couple of months ago I was asked by a client to create a method of patching to automatically snap shot a VM before applying the monthly patches with SCCM.

This as I’m sure your thinking has to be done by Task Sequence with the use of SCCM. If you not then that is how I would suggest you do it. The issue was PowerCLI and how to deploy that silently to all servers to allow for the Task Sequence to harness the PowerShell commands locally on the box without using remote PowerShell. I came across a great blog here discussing the silent install and then decided to write a PowerShell wrapper to deploy the software silently and with the use of SCCM.

The following script can be run as an Application or Package that is purely up to you. There are 2 modes, Install and Uninstall. Add these deployment command lines to your application or program to silently install PowerCLI or just run them locally:

[code language=”text”]
Powershell.exe -Executionpolicy Bypass -File "Deploy_PowerCLI_Silent.ps1 -MODE Install"
Powershell.exe -Executionpolicy Bypass -File "Deploy_PowerCLI_Silent.ps1 -MODE Uninstall"
[/code]

You will probably notice that to uninstall it silently you need to remove “VMware Remote Console Plug-in 5.1” followed by the “VMware vSphere PowerCLI” software.
The script build the arguments to do so, but if you are using a different version you will have to change:

[code language=”powershell”]$RemConsole = $InstalledProducts | where { $_.ARPDisplayName -eq "VMware Remote Console Plug-in 5.1" }[/code]

name to match
Just change the “VMware Remote Console Plug-in 5.1” portion to the same text as seen in your “Programs and Features” (Appwiz.cpl).
Make sure the VMware-PowerCLI.exe is in the same folder as the script.
The Script:

Error 0x80070193 – Automatic Deployment Rules Software Updates (ADR) SCCM

So the other day… I was setting up one of my clients Automatic Deployment Rules (ADR) for SCEP Definition Updates. Everything went fine until I went to run the rule and I saw “HttpSendRequest failed HTTP_STATUS_FORBIDDEN or HTTP_STATUS_DENIED” followed by “ERROR: DownloadContentFiles() failed with hr=0x80070193” in the PatchDownloader.Log file.

PatchDownloader.Log error 80070193
ERROR: DownloadContentFiles() failed with hr=0x80070193

This was a shock as this error usually only occurs when the traffic is blocked by a proxy server and at this customer site I was told to bypass the proxy using DNS host targeting.

After some trial and error it dawned on me. The System account of the machine must still be pointing to the clients proxy or using a PAC file. So I grabbed my trusty tool PSEXEC and spawned a CMD as System using a CMD as Administrator and the command: “PSEXEC.EXE -I -S CMD”

psexec_systemcmd
PSEXEC to launch CMD as “System”

After this I navigated to “c:\Program Files (x86)\Internet Explorer” and launched “Iexplore.exe”.

Run Internet Explorer as System
Run Internet Explorer as System

Then I navigated in IE to Tools, Internet Options and finally LAN Settings, and her presto there it was, it was grabbing a PAC file!

Automatically detect settings selected.
Automatically detect settings selected.

So I checked if I could browse to MSN and sure enough I was blocked.

With Automatically detect Settings enabled
With Automatically detect Settings enabled

So I unticked the box, restarted IE from the System CMD and tried again…  MSN! First time I think I had ever been happy to see that laggy page!

Without Automatically detect settings enabled.
Without Automatically detect settings enabled.

Jumped back into ConfigMgr (SCCM) and ran my ADR rule to find all definitions downloading successfully. Hope that’s helps someone out!

Successfully downloading definition patches!
Successfully downloading definition patches!

 

 

Copyright 2016 SCCMOG | All Rights Reserved