Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wslview produces a lot of errors and delays commands #320

Open
1 task done
landorg opened this issue Nov 12, 2024 · 6 comments
Open
1 task done

wslview produces a lot of errors and delays commands #320

landorg opened this issue Nov 12, 2024 · 6 comments
Assignees
Labels
Bug This is either an issue that describes a bug or a PR that resolves a bug

Comments

@landorg
Copy link

landorg commented Nov 12, 2024

Windows Version

Windows 11

Windows Build Number

22631.4317

WSL Version

WSL 2

Distro Version

Arch

WSL Utilities Version

4.1.1

Describe the bug

wslview takes a very long time and produced the errors below. In the end the browser is opened when I run this from terminal (not from emacs). This delays commands like gcloud auth login a lot.

This variable is not set $Env:__PSLockdownPolicy.

❯ wslview https://www.example.com
Cannot set property. Property setting is supported only on core types in this language mode.
At line:1 char:1
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]:: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertySetterNotSupportedInConstrainedLanguage

Cannot invoke method. Method invocation is supported only on core types in this language mode.
At line:1 char:59
+ ... ing]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::GetEnc ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage

Cannot invoke method. Method invocation is supported only on core types in this language mode.
At line:1 char:128
+ ... etEncoding(850); [Environment]::GetFolderPath('LocalApplicationData')
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage

wslpath: \Microsoft\WindowsApps\22955VineelSai.ArchWSL_qz230bc1wsk9j
Cannot set property. Property setting is supported only on core types in this language mode.
At line:1 char:1
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]:: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertySetterNotSupportedInConstrainedLanguage

Cannot invoke method. Method invocation is supported only on core types in this language mode.
At line:1 char:59
+ ... ing]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::GetEnc ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage

Steps to Reproduce

run wslview https://www.example.com

Expected behavior

No errors. Works fast

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@landorg landorg added the Bug This is either an issue that describes a bug or a PR that resolves a bug label Nov 12, 2024
@patrick330602
Copy link
Member

@landorg Can you try to set $ExecutionContext.SessionState.LanguageMode = 'fulllanguage' in your powershell and see what is the output? I suspect this related to this: https://overflow.seasi.dev/questions/57032747/how-to-change-powershell-mode-to-fulllanguage-mode-from-constrained-mode#57032893

@landorg
Copy link
Author

landorg commented Nov 18, 2024

Hi and thanks for your answer.
My PS is in constrained language mode yes. Not completely sure why as I am admin locally and no LockdownPolicy set.

PS C:\Users\username> $ExecutionContext.SessionState.LanguageMode
ConstrainedLanguage
PS C:\Users\username> $Env:__PSLockdownPolicy
PS C:\Users\username> $ExecutionContext.SessionState.LanguageMode = 'fulllanguage'
Cannot set property. Property setting is supported only on core types in this language mode.
At line:1 char:1
+ $ExecutionContext.SessionState.LanguageMode = 'fulllanguage'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertySetterNotSupportedInConstrainedLanguage

If I run PS as admin then it's in full language mode.

I tried to find the group policy that did this but I couldn't find it.

Is there a workaround available for my situation?
Thanks

@patrick330602
Copy link
Member

@landorg can you check if you have these set in the system? https://4sysops.com/archives/mitigating-powershell-risks-with-constrained-language-mode/

@landorg
Copy link
Author

landorg commented Nov 19, 2024

I think I have AppLocker. Seeing these events in the event viewer:

%OSDRIVE%\USERS\USERNAME\APPDATA\LOCAL\TEMP\__PSSCRIPTPOLICYTEST_NDC1EGZV.XOZ.PSM1 was prevented from running.

@patrick330602
Copy link
Member

Can you try to disable the rules using the methods in the article?

@landorg
Copy link
Author

landorg commented Nov 21, 2024

I don't think I can. Not sure if this is normal but I can't even see them in gpedit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is either an issue that describes a bug or a PR that resolves a bug
Projects
None yet
Development

No branches or pull requests

2 participants