Packages deployed as System context via SCCM

Prabhjot Singh 200 Reputation points
2024-08-26T13:27:13.8766667+00:00

Hi Team,

I hope you all are doing well. actually, I got stuck in a scenario where we have to deploy packages (Script package) as system context into devices via SCCM. Currently, what we are trying to do is, we need to deploy Script package as system context and needs to run inner part of script in user context.

Is there a way to trigger inner part of script as user context when deployed into devices as system context.

For reference, our current command line - %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -file

Do we need add any other parameter for triggering the inner part of script as user context when deploying as system context.

Do help to get through this. Thanks!

Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
964 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. XinGuo-MSFT 17,321 Reputation points
    2024-08-27T08:44:54.25+00:00

    Hi,

    You can use Invoke-Command to run a script block as a specific user. This requires the user credentials:

    Store User Credentials:

    $username = "DOMAIN\User"
    $password = ConvertTo-SecureString "password" -AsPlainText -Force
    $credential = New-Object System.Management.Automation.PSCredential($username, $password)
    
    

    Invoke Command as User:

    Invoke-Command -ScriptBlock { & "C:\Path\To\YourScript.ps1" } -Credential $credential
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.