ChrisTitusTech / winutil

Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates
MIT License
22.23k stars 1.35k forks source link

Can't run script. Get the following error: #2901

Open RichRay65 opened 2 hours ago

RichRay65 commented 2 hours ago

I run terminal in Admin mode and execute the script:

irm christitus.com/win | iex

I get the following error dump:

PS C:\Users\richa> irm christitus.com/win | iex
iex : At line:14455 char:5
+     class WingetFailedInstall : Exception {
+     ~~~~~
Class keyword is not allowed in ConstrainedLanguage mode.
At line:14455 char:11
+     class WingetFailedInstall : Exception {
+           ~~~~~~~~~~~~~~~~~~~
Unexpected token 'WingetFailedInstall' in expression or statement.
At line:14461 char:5
+     class ChocoFailedInstall : Exception {
+     ~~~~~
Class keyword is not allowed in ConstrainedLanguage mode.
At line:14461 char:11
+     class ChocoFailedInstall : Exception {
+           ~~~~~~~~~~~~~~~~~~
Unexpected token 'ChocoFailedInstall' in expression or statement.
At line:14467 char:5
+     class GenericException : Exception {
+     ~~~~~
Class keyword is not allowed in ConstrainedLanguage mode.
At line:14467 char:11
+     class GenericException : Exception {
+           ~~~~~~~~~~~~~~~~
Unexpected token 'GenericException' in expression or statement.
At line:1 char:26
+ irm christitus.com/win | iex
+                          ~~~
    + CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
    + FullyQualifiedErrorId : ClassesNotAllowedInConstrainedLanguage,Microsoft.PowerShell.Commands.InvokeExpressionCom
   mand

PS C:\Users\richa>

Any ideas?

ps. I was able to run this in the past successfully.

MyDrift-user commented 2 hours ago

Hello @RichRay65

This is the same as #1994, try following:

$ExecutionContext.SessionState.LanguageMode = "FullLanguage"

We cuurently do not have a fix for it appearing at all, bc this is essencially a way to restrict scripts, which winutil is.

RichRay65 commented 1 hour ago

Thanks!

I removed this environment variable __PSLockDownPolicy and it works again.

On Wed, Oct 9, 2024 at 2:08 PM MyDrift @.***> wrote:

Hello @RichRay65 https://github.com/RichRay65

This is the same as #1994 https://github.com/ChrisTitusTech/winutil/issues/1994, try following:

$ExecutionContext.SessionState.LanguageMode = "FullLanguage"

We cuurently do not have a fix for it appearing at all, bc this is essencially a way to restrict scripts, which winutil is.

— Reply to this email directly, view it on GitHub https://github.com/ChrisTitusTech/winutil/issues/2901#issuecomment-2403197233, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOA2PQDDH4QOL4EV2OOL2WTZ2V5LFAVCNFSM6AAAAABPVGAZZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBTGE4TOMRTGM . You are receiving this because you were mentioned.Message ID: @.***>