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 a user?  Quick and easy way to make the PowerShell ISE available for you to test running your scripts as System.  Nope, it’s not PSExec… this is even easier.

Super Simple, almost feel it’s not even blog worthy, but here it is anyway.

  • Make a Package, no Content (PowerShell ISE x64)
  • Make a program (RunAsSystem)
    • Command: %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe –command “ise”
  • Program Environment  – Only when a user is logged on – Check Box “Allow Users to interact with this program”

image

image

Then Deploy it to a user or user group, very limited test group, as this gives anyone with this deployment full system access to their machine.

image

When you click Install, you’ll see the black command window for a second, then the ISE start launching. Once Launched, you’ll see it is running as System.

image

Now you can test your script under the same context that CM would run this.  I use this all the time to test things I plan to load into the scripts node.

If you just want to launch a command prompt:
Program:

  • 32bit CMD: cmd.exe /c start cmd.exe
  • 64bit CMD: cmd.exe /c start c:\windows\sysNative\cmd.exe

Posted on GARYTOWN.COM

8 thoughts on “Run PowerShell ISE as System to Test scripts… From Software Center”

  1. Nice little trick 😉 I saw you offer Greenshot as a deployment. Can you tell me how you did this because at every silent install the user receives an internet page from Greenshot.

    Reply
  2. @Michael, try this in a batch script for Greenshot…

    start /wait “Installing Greenshot…” “%~dp0Greenshot-INSTALLER-1.1.9.13.exe” /LOADINF=”%~dp0greenshot.inf” /LOG /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-

    This is my Greenshot.inf file content
    [Setup]
    Lang=en
    Dir=C:\Program Files\Greenshot
    Group=Accessories\Greenshot
    NoIcons=0
    SetupType=custom
    Components=greenshot,plugins\office,plugins\ocr,plugins\externalcommand
    Tasks=startup

    I’m also copying a modified Greenshot-defaults.ini file to the install folder, but I don’t thing that is required.
    This worked for me as of version 1.1.9.13

    Reply
  3. Hmm, love the idea. What if you do this so it opens a script? My thinking is to have the script open in PowerShell ISE so the users can run only the selected portions of the script they want

    Reply
  4. I gave both of these a try, and nothing happened, they never appeared on the screen. At least if that happened, I could navigate to the script I want to run.

    Reply
    • Not sure, I just rebuilt following the blog post exactly, and it worked.
      I’d suggest double checking your settings on the program. Make sure ‘Only when a user is logged on’ & ‘Allow Users to interact with this program’ are set.

      Reply
  5. Only the cmd works, but not when using the sysnative path. When I use that path, it fails with path not found error. I am happy if only the cmd works, I can just launch PowerShell_ise from in there and get the same result, thanks again.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.