I have an odd behavior with PS in a new Acer laptop.

I straight up copied the folder with the scripts from my PC on a USB drive and tried to use them on the laptop (both directly on the pendrive and copied them in local drive), so scripts that I know that run (tested and used them on the PC and on another laptop), but when I right clicked and selected "Run with Powershell" I only saw PS window flashing open-and-close, no matter which script I tried to run (and they are all scripts with at least a Read-Host inside).

The same scripts, when called with ".\" inside an already open PS window, work just fine and even other scripts called by that script work just fine, like a Scoop installer script that downloads it and then runs it (and after that installs basic things like 7zip, git, aria...).

To try to solve

I checked and modified the execution policies, but to no avail.

On my PC (Win 11 PS 7.3.9):

Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    RemoteSigned

and everithing works just fine, while on 2 laptops (Win 11 PS 7.4):

Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Unrestricted
 LocalMachine       Undefined

and on one everithing works just fine, while on the other not so much...

I tried to deactivate PS, reboot and reactivate it and reboot again; I uninstalled the preinstalled McAfee (the only thing present except for some Acer programs) and rebooted, rebooted again...

I searched on the internet and found only another guy with apparently the same problem (not caused by policies), but in his case it was an apostophe in the filepath, which is not my case since there aren't (and by copying the folder, if that path is legit on a PC it should be legit on others with the same OS, too).

What can I do to solve or even to see what could be the problem? Did I forget something?

Bonus odd behavior: accented letters work and not, don't know how or why. a simple accent.ps1 with

Write-Verbose "àèìòù" -Verbose
Write-Host "àèìòù"

shows the accents correctly, while the Scoop install script (that checks if it's already installed), in the phrase "Scoop già installato" (Scoop already installed) the "à" looks like a quest mark ("?" inside a square), obvoiusly this behavior, too, is present only in the Acer...

EDIT: ok, as said in the comments, thanks to iRon, PowerShell 5 and 7 have two different and separated execution policies and it's PS5's execution policies that need to be changed.

Now the accented letters situation is inverted: accent.ps1 doesn't render properly when opened with PS5 (but it's ok with PS7), while the Scoop install script renders properly with PS5 (but doesn't render accented letters with PS7).

0

There are 0 answers