Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
2 votes
2 answers
209 views

I am trying to have a powershell script called from a C# program give me the exit code of the powershell script. I have attempted it a few ways with no success. The PSObject from the invoke call ...
1 vote
1 answer
72 views

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 ...
KarloX's user avatar
  • 1,017
1 vote
1 answer
91 views

So writing a C# program that uses a powershell script as follows PowerShell allowtorthroughwindowsfirewallinbound = PowerShell.Create("New - NetFirewallRule - DisplayName Allow TOR through ...
user avatar
1 vote
1 answer
81 views

I am trying to invoke a powershell script that makes use of tokens. var results = powerShell.Invoke(); if (powerShell.HadErrors) { foreach (var error in powerShell.Streams.Error) { ...
1 vote
1 answer
157 views

I'm trying to create a RunspacePool with an initial session state and a count of min/max runspaces. However, the only constructor on RunspaceFactory that supports all those parameters also requires a ...
1 vote
1 answer
595 views

I have a simple .NET 7 class library referencing this NuGet package (NO other ORACLE packages are included): <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21....
2 votes
1 answer
150 views

I'd like to call a PowerShell script in c#. In Terminal the command would look like get-mailbox -RecipientTypeDetails "EquipmentMailbox","RoomMailbox" I can get it to run if I ...
3 votes
2 answers
167 views

From PowerShell we can easily check if a caller is using Windows PowerShell 5.1 or a newer version using the $PSVersionTable automatic variable: if ($PSVersionTable.PSVersion -ge '7.0') { # do 7+ ...
0 votes
1 answer
97 views

I have created the following C# code to run a powershell script: static void Main(string[] args) { PowerShell ps = PowerShell.Create(); string script = ""; ...
0 votes
1 answer
51 views

I am using Microsoft.PowerShell.SDK (Version 7.3.3) in order to clone a git repository from C# like this: (Note: I know there is libgit2sharp, but it doesn't support all of my use cases). using (...
Tim Meyer's user avatar
  • 12.7k
1 vote
2 answers
2k views

For the context, I'm building an app that will read and update the Custom Security Attributes of Azure AD users. I'm using the beta version. Here is my code: # Connect to the client Function Invoke-...
1 vote
1 answer
261 views

I am trying to insert a registry entry with a PowerShell script using C#. This is my code: public void ExecuteCommand(string script) { Runspace runspace = RunspaceFactory.CreateRunspace(); ...
1 vote
2 answers
1k views

I'm executing a script with the PowerShell SDK, which makes use of all different streams (information, warning, verbose, ..). I can capture the output from them correctly, but not in the sequence they ...
0 votes
1 answer
92 views

The short question Why, when I run the Get-Command powershell command within a .NET 5.0 application using the Microsoft.PowerShell.SDK nuget package I get different results on different systems, and ...
0 votes
0 answers
56 views

I am doing an automatic build of C# applications on a web server with IIS 10.0, my code generates a command for PowerShell.SDK. using(PowerShell pws = PowerShell.Create()) { var cmd = $"set-...

15 30 50 per page
1
2 3

AltStyle によって変換されたページ (->オリジナル) /