File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
operating-systems/windows Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,40 @@ taskkill /PID targetpid
307307
308308## Powershell commands
309309
310+ ### PS1 Scripts
311+
312+ ``` powershell
313+ # 1. Run the script with Bypass mode (One-time execution)
314+ powershell -ExecutionPolicy Bypass -File <SCRIPT.ps1>
315+ # Shorter version
316+ powershell -ep Bypass -f <SCRIPT.ps1>
317+
318+ # 2. Temporarily set execution policy for the current session
319+ Set-ExecutionPolicy Bypass -Scope Process -Force
320+ <SCRIPT.ps1> # Now run the script
321+
322+ # 3. Unblock the script file (if marked as untrusted)
323+ Unblock-File -Path <SCRIPT.ps1>
324+ <SCRIPT.ps1> # Try running again
325+
326+ # 4. Run the script without changing execution policy (using Invoke-Expression)
327+ powershell -Command "Get-Content <SCRIPT.ps1> | Invoke-Expression"
328+ # Alternative (more compact)
329+ iex (Get-Content <SCRIPT.ps1> -Raw)
330+
331+ # 5. Change execution policy permanently (requires admin)
332+ Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force # Allows all scripts
333+ Set-ExecutionPolicy RemoteSigned -Scope LocalMachine -Force # Allows only signed remote scripts
334+
335+ # 6. Run with -NoProfile to ignore execution policies
336+ powershell -NoProfile -ExecutionPolicy Bypass -File <SCRIPT.ps1>
337+
338+ # 7. Reset execution policy back to restricted (optional, for security)
339+ Set-ExecutionPolicy Restricted -Scope CurrentUser -Force # Blocks all scripts again
340+ ```
341+
342+
343+
310344### [ Winget] ( https://learn.microsoft.com/en-us/windows/package-manager/winget/upgrade )
311345
312346``` bash
You can’t perform that action at this time.
0 commit comments