I tried 2 test.
1st test.
I opened PowerShell console, I run script .ps1 which you described.
Here is output:
Get-Item : Cannot find path 'HKCR:\.ps1\OpenWithProgids' because it does not exist.
At C:\Users\administrator.AUSL6\Desktop\test cruscotto auto di battaglia\prova.ps1:3 char:1
+ Get-Item "HKCR:\$($assoc.split('=')[0])\OpenWithProgids"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCR:\.ps1\OpenWithProgids:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
Hive: HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open
Name Property
---- --------
Command (default) : "C:\Windows\System32\notepad.exe" "%1"
2nd test.
I Open by, Windows Explorer, new windows and I click on script ps1 which you described.
I got :
. : The term 'C:\Program Files (x86)\VMware\Infrastructure\vSpherePowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ . "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Program File...Environment.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException