/build/static/layout/Breadcrumb_cap_w.png

Run PowerShell script using Domain User Account

Hello,

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

Answers (2)

Posted by: rileyz 8 years ago
Red Belt
0
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?

Comments:
  • 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\\";
    }; - nma7916 8 years ago
    • 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. - rileyz 8 years ago
      • 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! - nma7916 8 years ago
      • 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! - rileyz 8 years ago
      • I checked the script and it work. But I need to now figure out a way to run the script using SCCM - nma7916 8 years ago
Posted by: andys0123 8 years ago
Orange Senior Belt
0

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!


Comments:
  • I checked my system and I already had all that written in the command line and it still isn't work :( - nma7916 8 years ago
    • 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. - andys0123 8 years ago
 
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