A system context runs a script under the operating system’s system account instead of an interactive user. It suits unattended automation when the task needs machine-level access or should avoid storing a password. section 4.1.3 section 11.4.2
Choose the system context deliberately:
- Use it when elevated permissions or machine-level locations are required, such as Program Files, Program Data, or the machine registry. section 11.4.2
- Avoid it for user-specific settings because the system account lacks the interactive user profile and HKCU access. section 11.4.2
- Test the commands first as an administrator, then under a standard user and the system context; combine execution methods when necessary. section 11.4.2
Unattended SQL health check
When SQL Server uses Windows domain authorization, schedule the health-check script to run as the authorized account. Alternatively, run it locally on the database server under the system context, avoiding a stored username and password while restricting execution to that server. section 4.1.3
.\git-install.ps1 -branch 'main' Chocolatey v0.12.1 Installing the following packages: git.install By installing, you accept licenses for the packages. Progress: Downloading git.install 2.35.1.2... 100% chocolatey-core.extension v1.3.5.1 [Approved] chocolatey-core.extension package files install completed. Performing ot... Installed/updated chocolatey-core extensions. The install of chocolatey-core.extension was successful. Software installed to 'C:\ProgramData\chocolatey\extensions\chocola... git.install v2.35.1.2 [Approved] git.install package files install completed. Performing other installa... Using Git LFS Installing 64-bit git.install... git.install has been installed. Environment Vars (like PATH) have changed. Close/reopen your shell to see the changes (or in powershell/cmd.exe just type `refreshenv`). The install of git.install was successful. Software installed to 'C:\Program Files\Git\' Chocolatey installed 2/2 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Inspect the system-context Git installation output produced through Invoke-CommandAs; related listings show the resulting system-level Git configuration. section 11.4.2
