Repository navigation
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of moduleshosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I am experiencing a problem when running the PowerShell SDK in a kiosk (AssignedAccess) environment in a WindowsBackgroundService. When I am using the library in a non-kiosk environment it works fine. But the weird thing is that once I am in the kiosk or when I get back from it, I am always getting an exception. I already asked this on StackOverflow but without any solutions.
Expected behavior
$user = "ExamX"
$Sid = (Get-LocalUser -Name $user).SID.Value
Remove-LocalUser -SID $Sid
Clear-AssignedAccess
sc.exe stop "ExamX Service"
sc.exe delete "ExamX Service"
$path = "HKLM:\SOFTWARE\ExamX\ExamInfo\"
Remove-Item -Recurse $path -ErrorAction SilentlyContinueActual behavior
Exception Trace System.TypeInitializationException: The type initializer for 'System.Management.Automation.ExperimentalFeature' threw an exception.
---> System.TypeInitializationException: The type initializer for 'System.Management.Automation.Configuration.PowerShellConfig' threw an exception.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at System.Management.Automation.Configuration.PowerShellConfig..ctor()
at System.Management.Automation.Configuration.PowerShellConfig..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.ExperimentalFeature..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at ExamX_Service.WindowsService.PowershellHandler.Execute() in C:\ExamX\Service\ExamX_Service\ExamX_Service\PowershellHandler.cs:line 33
at ExamX_Service.WindowsService.WindowsBackgroundService.RunRecoveryScript(ILogger`1 logger) in C:\ExamX\Service\ExamX_Service\ExamX_Service\WindowsBackgroundService.cs:line 134
at ExamX_Service.WindowsService.WindowsBackgroundService.ExecuteAsync(CancellationToken stoppingToken) in C:\ExamX\Service\ExamX_Service\ExamX_Service\WindowsBackgroundService.cs:line 110Error details
No response
Environment data
I can't really execute this command due to the exception being thrownVisuals
No response
Reacted by Marc Le Pech and yoavt-semperis
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of moduleshosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules
Activity
SteveL-MSFT commentedon Oct 4, 2022
Based on the stacktrace, it seems that somehow this is returning
nullPowerShell/src/System.Management.Automation/engine/Utils.cs
Lines 484 to 489 in fd67038
ProRedMax commentedon Oct 5, 2022
So I am using a fresh virtual machine (So I am not hosting PowerShell in any way I know) and just calling the PowerShell library. As I mentioned it works fine in a non-kiosk environment. The weird thing is that when I return from the kiosk it still does not work. This is how I am using the library:
Call in WindowsBackgroundService.cs
And this is the actual PowershellHandler:
FeelProud commentedon Nov 24, 2022
I would like to support this problem that I have also just encountered.
Setup :
My application :
Explanation :
I'm using this following code in my background service
And I'm getting the following error
SteveL-MSFT commentedon Nov 28, 2022
What specific version of the PowerShell SDK are you using?
ProRedMax commentedon Nov 29, 2022
I am using 7.2.5
FeelProud commentedon Nov 29, 2022
I am using 7.2.7 for my part
tannertaylor commentedon Nov 30, 2022
Just wanted to throw my voice in here as well. I'm getting this exact error with a self-contained single-file app. I'm using version 7.2.4. The PR looks like it ought to fix my problem.
jacknovacloud commentedon Dec 14, 2022
7.3.0 and getting the same issue with a self contained single file app
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 30, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.