on-internet
← Community

How to Restrict PowerShell SDK to Limit Script Access to Specific Callback Methods in a C# Application?

Stack Overflow ·

In my C# application I want to use the PowerShell SDK to allow user-provided PS scripts to interact with limited parts of the application through callbacks. I want to restrict what these scripts can do, ideally allowing only specific methods to be called on a provided callback interface, without giving full access to system resources or sensitive .NET types. Here’s a simplified code example: var iss = InitialSessionState.CreateRestricted(SessionCapabilities.Language); iss.LanguageMode = PSLanguageMode.FullLanguage; // ConstrainedLanguage would inhibit the callbacks // Add specific cmdlets, for

Comments

Sign in or sign up to comment and upvote.

No comments yet.