220-1102 Question 784
Single answer.ps1A help desk technician receives a PowerShell script named Inventory.ps1 from the IT manager to collect basic hardware information from several Windows 11 PCs. When the technician double-clicks the file, it does not run. The technician then opens PowerShell and tries to execute the script, but receives a message indicating that running scripts is disabled on the system. The technician wants to run only this script for the current PowerShell session without broadly lowering security settings for the computer. Which action should the technician take first?
- A
Change the execution policy to Unrestricted for the LocalMachine scope
- B
Run PowerShell as administrator and rename the file to Inventory.bat
- C
Set the execution policy to Bypass for the current PowerShell process, then run the script
- D
Move the script into C:\Windows\System32 so PowerShell will treat it as trusted
Show answer and explanation
Correct answer: C
Explanation
A .ps1 file is a Windows PowerShell script. By default, many systems restrict script execution through PowerShell execution policies. In this scenario, the best practice is to use the least permissive change necessary. Setting the execution policy for the Process scope, such as using Bypass for just the current PowerShell session, is appropriate when a technician needs to run a trusted script one time without changing the policy for other users or future sessions. Changing LocalMachine to Unrestricted is too broad and reduces security. Renaming the file extension does not change the script language, and moving the file to a system folder does not bypass execution policy. Microsoft documentation on PowerShell execution policies describes scopes such as Process, CurrentUser, and LocalMachine, and supports using the narrowest scope needed for administrative tasks.
- A. Incorrect.
This is incorrect because setting the execution policy to Unrestricted at the LocalMachine scope changes script behavior for the entire system, which is broader than necessary. The scenario specifically asks for a way to run only this script in the current session without weakening security for all users or future sessions.
- B. Incorrect.
This is incorrect because simply renaming a .ps1 file to .bat does not convert a PowerShell script into a valid batch file. The commands and syntax are different, and the script would likely fail. Running PowerShell as administrator also does not by itself solve an execution policy restriction.
- C. Correct.
This is correct because using a process-scoped execution policy such as Bypass applies only to the current PowerShell session. This allows the technician to run the needed .ps1 script without changing the machine-wide policy. This is a practical, least-impact approach when a one-time script must be executed.
- D. Incorrect.
This is incorrect because placing a script in C:\Windows\System32 does not automatically make PowerShell trust or execute it. Execution policy and, in some cases, file origin markings still apply. Moving scripts into system folders is also poor practice and can create administrative and security issues.