0

"test" , Get-ExecutionPolicy -list ..

the only command before the start is Set-ExecutionPolicy Bypass -Scope Process . whether i then do Set-ExecutionPolicy RemoteSigned -Scope Process , the issue doesn't change .

i found out that it doesn't happen in some cases

  • Get-ExecutionPolicy -list provides no console output
    $v = Get-ExecutionPolicy
    if ($v -eq "Bypass") {
    
        Get-ExecutionPolicy -list
    }
    
    read-host -prompt "Press Enter to continue..."
    
  • Get-ExecutionPolicy -list provides the output, kind of
    Get-Item -Path Env:*
    
    $v = Get-ExecutionPolicy
    if ($v -eq "Bypass") {
    
        Get-ExecutionPolicy -list
    }
    
    read-host -prompt "Press Enter to continue..."
    
irvnriir
  • 673
  • 5
  • 14
  • 1
    Try `Get-ExecutionPolicy -List | Out-Host` to force _synchronous_ output, so that it is shown before the `pause` command's prompt - see [this answer](https://stackoverflow.com/a/43691123/45375) for background info. – mklement0 Mar 20 '22 at 01:59
  • 1
    @mklement0 perfect, thanks aloooooot . i was struggling with this issue at different locations, for months . – irvnriir Mar 20 '22 at 02:02
  • Glad to hear it helped; I suggest closing your question as a duplicate of the linked post. On a general note: It's a tricky and obscure problem that I wish would finally get fixed - see https://github.com/PowerShell/PowerShell/issues/4594 and, for an even more problematic manifestation, https://github.com/PowerShell/PowerShell/issues/13985 – mklement0 Mar 20 '22 at 02:16

0 Answers0