There will be a use-case, but as for now, here’s an early version of the engine. What it allows you to do:
Run scripts as the user rather than system. (If you want to. Got a param for it)
Target users logged on to a computer (sort of) using the fast channel.
UserWrapper.ps1 -> Import this script in the SCCM-console. This is the wrapper for every script that you might deploy and it will be static, no need to import another version of it just to deploy a new script. This of course have security impacts. Every user that has a role which allows the user to run scripts (but not to create nor approve them) can bypass those restrictions by calling this script.
So I recommend creating some kind of countermeasure, like a security scope or such which only allows users that can create scripts to run this one.
I’ve created a function within the script which prevents it to execute the downloaded script if the client OS is anything but a workstation. Once you’ve experienced a required deployment targeting a user resource you know why. ;P
Msgbox3.ps1 -> The script that this POC will download and trigger. Nothing out of the ordinary, shows a msgbox top most if launched interactively or writes the same text to the log if it’s not.
Invoke-SCCMScriptUserTarget.ps1 -> This is the script to run and edit to automatic things. Passes the script to download, the hash of it and some other stuff to the UserWrapper. I’m using @johnsson_r Invoke-SCCMRunScript.ps1 since Invoke-CMScript doesn’t support passing parameters, at least not in 1810 which is our current version.
The use case might seem vague, but there’s a reason this is called Part 1 =)
You can find the scripts over here: https://github.com/MattiasC85/Scripts/tree/master/ScriptUserWrapperPOC
Comments