PowerShell 7.3 - Inconsistent Behavior When Using Start-Process with PowerShell Script Arguments
I'm optimizing some code but I'm working with an scenario with the `Start-Process` cmdlet in PowerShell 7.3 when trying to run a PowerShell script with arguments... The command works perfectly in the PowerShell console, but when executed through `Start-Process`, it throws an behavior indicating that the script want to be found. Here's the command I used: ```powershell $scriptPath = 'C:\Scripts\MyScript.ps1' $arguments = '-Param1 Value1 -Param2 Value2' Start-Process -FilePath 'powershell.exe' -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File', $scriptPath, $arguments ``` When I run this, I receive the following behavior: ``` File C:\Scripts\MyScript.ps1 want to be loaded because running scripts is disabled on this system. ``` I've already checked the execution policy, and it is set to `Unrestricted` when I run `Get-ExecutionPolicy`. I also tried using `-ExecutionPolicy Bypass` in the `Start-Process` command, but it still fails. Interestingly, if I run the script directly in the console, it executes without any issues. I've tried specifying the full path for `powershell.exe` as well, but the question continues. Is there a specific syntax or method I should be using to pass arguments to a PowerShell script when invoking it via `Start-Process`? Any help would be appreciated! Any ideas what could be causing this? This is my first time working with Powershell stable. Any feedback is welcome!