Closed DavidAGullo closed 1 year ago
nvm I think I found it through a different method:
string username = "username";
using (var runspace = RunspaceFactory.CreateRunspace())
{
using (var powerShell = PowerShell.Create())
{
string script = "Get-ADPrincipalGroupMembership " + username + " | select name";
`
//start powershell script
powerShell.Runspace = runspace;
powerShell.Runspace.Open();
powerShell.AddScript(script);
foreach (PSObject result in powerShell.Invoke())
{
Console.WriteLine("{0}", result);
} // End foreach.`
Question Wondering if a command like: Get-ADPrincipalGroupMembership username | select name
where the username would be inserted by the program
Just wondering if this is possible? I don't see how to do it in the Documentations I got: Get-ADPrincipalGroupMembership username working just fine