gerardog / gsudo

Sudo for Windows

Home Page:https://gerardog.github.io/gsudo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: `ParentContainsErrorRecordException` when using `gsudo { Get-NetIPAddress }`

cloud-yu opened this issue · comments

Issue Description

gsudo { Get-NetIPAddress } end up with an error

Steps to Reproduce

image

with --debug

Debug: Invoking Shell: PowerShellCore
Debug: Command Line: --debug -encodedCommand IABHAGUAdAAtAE4AZQB0AEkAUABBAGQAZAByAGUAcwBzACAA -inputFormat xml -outputFormat text
Debug: Applying workaround for target app installed via MSStore.
Debug: Command to run: C:\WINDOWS\system32\cmd.exe /v:on /s /c ""C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.1.0_x64__8wekyb3d8bbwe\pwsh.exe" -NoLogo -NoProfile -encodedCommand IABHAGUAdAAtAE4AZQB0AEkAUABBAGQAZAByAGUAcwBzACAA -inputFormat xml -outputFormat text"
Debug: Using Console mode TokenSwitch
Debug: Caller PID: 6140
Debug: Caller SID: S-1-5-21-3861694489-1318466560-650796685-1002
Debug: Elevating process: C:\Program Files\gsudo\2.4.4\gsudo.exe --debug gsudoelevate 6140 S-1-5-21-3861694489-1318466560-650796685-1002 All 00:00:00
Debug: Service process started.
Debug: Connected via Named Pipe ProtectedPrefix\Administrators\gsudo_4B66ADB72EB4FAECCD55F24FDFFF0ED1A190F775E230E330C00313D5F39CA336.
Debug: Creating target process: C:\WINDOWS\system32\cmd.exe /v:on /s /c ""C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.1.0_x64__8wekyb3d8bbwe\pwsh.exe" -NoLogo -NoProfile -encodedCommand IABHAGUAdAAtAE4AZQB0AEkAUABBAGQAZAByAGUAcwBzACAA -inputFormat xml -outputFormat text"
Debug: Process token successfully substituted.
ParentContainsErrorRecordException:
Line |
 622 |      $__cmdletization_objectModelWrapper.ProcessRecord($__cmdletizatio …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "ProcessRecord" with "1" argument(s): "The type initializer for 'Microsoft.Management.Infrastructure.Native.ApplicationMethods' threw an exception."
Debug: Process exited with code 1

image

Context:

  • Windows version:
    Windows 11 23H2 (22631.3235)
  • gsudo version:
     gsudo --version                                                                                                                                                                       
     gsudo v2.4.4 (Branch.tags-v2.4.4.Sha.cf887bf98d5d3d90fc1eebc08c7a277afb50cd19)
     Copyright(c) 2019-2022 Gerardo Grignoli and GitHub contributors
    

it only occurs with pwsh is installed by msstore
works fine when reinstall it by .msi package

I also have Pwsh 7.4.1 installed via msstore (at C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.1.0_x64__8wekyb3d8bbwe\pwsh.exe), and it is working fine for me...

image

I need additional information to detect where the problem is, for example, what happenes if you use the msstore Pwsh and run: pwsh {get-NetIPAddress}

Thank you

Sorry, I can't reproduce this problem after reinstall win11, looks like this is a win11 problem.
I think I should close this issue

No problem, others finding this error message while using gsudo can +1 here. Thank you @cloud-yu