Run PowerShell ISE as System to Test scripts… From Software Center

Yet another post caused by my recent rebuilding of my lab from scratch after I totally hosed my last CM Server.  This time I’m documenting (blogging) a few additional things. So you write a lot of scripts for ConfigMgr?  Notice that they sometimes don’t perform quite as expected because they run as system instead of … Read more

Scripts Node, Add Local & Network Logging to Script

This is basically two posts in one, add logging to your scripts in the script node, and Get Service Windows Info, check if you have any deployments being squashed by too restrictive Services Windows, and remove the service windows if you want to.  Why add logging… several reasons, to know what the script did, to have a “paper trail”, and helps with troubleshooting.  I’ve added logging to my scripts for accountability as well.  I have it log to a network share because I’m not local admin on the boxes I’m running the scripts on, so having a central share to collect the scripts is very important to me when I’m troubleshooting issues.

The reason I wrote this script was because we’ve run into machines that would never run the Upgrade because they would return with a status message “deployment will never run, too restrictive of service window”.  We do not check the box on our deployments to run outside of a Service Window, as we want to respect what the Business Unit have said are their approved times to service machines.  However there are times when the windows are just too small for the time we’ve specified in our TS, or someone created a local service window manually, using a tool like Client Center, to accomplish a one-off task and never cleaned it up.  So I created a script that would read the execmgr.log file, search for a restrictive window issue, then delete them (based on parameters).  You can search for Local Service Windows or Server Side (Collection) Service Window and delete those, or choose Delete all service windows.  Common Sense Warning:  Use with Caution, and Test please.  This script is deleting Service Windows which restrict installs / reboots from happening all willy nilly.  If you start removing those restrictions… well.. you get it.

image

Read more

Test Low Disk Space / Create Large Test File

So I stole this code from my friend Keith G, who provided it to assist with testing scenarios to see if our safe guards would work.
Basically, the 1 line command will check your drive, then create a dynamically sized file to leave “XX” GB remaining.  In my command, I leave only 15GB Free, which is low enough to trigger a failure on our in place upgrades.  Then I can test to make sure the the IPU TS fails the way I expect, running the proper remediation steps, and records the metrics for reporting.

Code: (run in elevated PowerShell Console)

get-volume c | % {$_.SizeRemaining - 15GB} |  % {Fsutil file createnew c:\TestFile.id $_}

So I made it into an App, I’ve added a few items into the app model to allow me to “install” it quickly on a machine to test failure scenarios.

App Code:

powershell.exe -command "get-volume c | % {$_.SizeRemaining - 15GB} |  % {Fsutil file createnew c:\TestFile.id $_}"

Read more

Get Package CCMCache Location

Ever want to know where in the CCMCache the content was located for that package that was downloaded?  Ever think you found it, then figured out it wasn’t the most updated version of the content?  I quick wrote this script to help me find where in the cache the content is located, and spits back the most updated version of it.

Read more