Scripting Question

Run PowerShell script using Domain User Account

11/17/2016 3887 views

I have a script to change the ccm cache size for computers on my network. I have tried to deploy the script using SCCM however I need it to run as the SCCM User Account because that has domain user rights. How can specifically run with that account? I tried researching online but no definitive answers. Thank you in advance!
0 Comments   [ + ] Show comments


All Answers

Is there a reason you why cant change the cache size using the system account? I thought the call to change the sccm cache size use WMI so it should be ok?
Answered 11/18/2016 by: rileyz
Red Belt

  • The System account doesn't seem to work. Should it be able to?

    I tried running it and it fails with the error code 0x1(1).

    I know the script works because I ran it using my domain account and it changed the size properly and everything.

    If this helps, I attached the log text:

    Raising event:
    [SMS_CodePage(437), SMS_LocaleID(1033)]
    instance of SoftDistProgramStartedEvent
    AdvertisementId = "5472005E";
    ClientID = "GUID:4104B4F3-0067-48EA-BBC9-7F0BA9A35054";
    CommandLine = "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoLogo -NonInteractive \"C:\\windows\\ccmcache\\i\\changecachesize.ps1\"";
    DateTime = "20161116230319.972000+000";
    MachineName = "03033D";
    PackageName = "547000EF";
    ProcessID = 4884;
    ProgramName = "Cache Size Modification";
    SiteCode = "547";
    ThreadID = 8392;
    UserContext = "NT AUTHORITY\\SYSTEM";
    WorkingDirectory = "C:\\windows\\ccmcache\\i\\";
    • Get Sysinternals PSEXEC and run PowerShell as SYSTEM and test your script.

      The command is
      psexec -s -i powershell
      to get powershell to launch as the system account.
      • Is "psexec -s -i powershell" the command I type into cmd after installing PSEXEC? Or...? I'm sorry I'm a little unfamiliar with all of that!
      • Download psexec
        open cmd and switch dir where psexec is located.
        In the command windows type "psexec -i -s powershell"

        This should pop a box for licence agreement, hit ok, then the powershell window will open, type "whoami" check that you are running as NT/SYSTEM

        From here use the powershell window as normal to test your script.

        Boom, its the weekend, im outta here!
      • I checked the script and it work. But I need to now figure out a way to run the script using SCCM

Try adding

-ExecutionPolicy Bypass

after the PowerShell.exe in your command line:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NoLogo -NonInteractive "C:\windows\ccmcache\i\changecachesize.ps1"

This will run the PowerShell session with less security, so not to be used lightly!

Answered 11/24/2016 by: andys0123
Orange Senior Belt

  • I checked my system and I already had all that written in the command line and it still isn't work :(
    • The command line in your post above doesn't show any ExecutionPolicy parameter:

      CommandLine = "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoLogo -NonInteractive \"C:\\windows\\ccmcache\\i\\changecachesize.ps1\"";

      Can you check it again, please.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ