Click here to Skip to main content
15,909,651 members
Home / Discussions / C#
   

C#

 
QuestionCostura.Fody fails on govt. network Pin
Member 1348136130-Aug-18 10:37
Member 1348136130-Aug-18 10:37 
AnswerRe: Costura.Fody fails on govt. network Pin
Dave Kreskowiak30-Aug-18 10:51
mveDave Kreskowiak30-Aug-18 10:51 
GeneralRe: Costura.Fody fails on govt. network Pin
Member 1348136130-Aug-18 15:09
Member 1348136130-Aug-18 15:09 
GeneralRe: Costura.Fody fails on govt. network Pin
Dave Kreskowiak30-Aug-18 15:52
mveDave Kreskowiak30-Aug-18 15:52 
QuestionRemove-DistributionGroupMember not found in Powershell Runspace Pin
Chad Underwood30-Aug-18 2:45
Chad Underwood30-Aug-18 2:45 
AnswerRe: Remove-DistributionGroupMember not found in Powershell Runspace Pin
Richard Deeming30-Aug-18 6:41
mveRichard Deeming30-Aug-18 6:41 
GeneralRe: Remove-DistributionGroupMember not found in Powershell Runspace Pin
Chad Underwood30-Aug-18 8:15
Chad Underwood30-Aug-18 8:15 
AnswerRe: Remove-DistributionGroupMember not found in Powershell Runspace Pin
Chad Underwood31-Aug-18 4:57
Chad Underwood31-Aug-18 4:57 
I went back and re-wrote my script after playing around with this
Programmatic Access via Remote PowerShell in Exchange Server 2010 – You Had Me At EHLO…[^]

Here is the working version in case anyone has a need for it.

public void RemoveUserFromGroup()
{
    string connectionUri = "https://outlook.office365.com/powershell-liveid/";
    System.Security.SecureString secureString = new System.Security.SecureString();
    string myPassword = loginPassword;
    foreach (char c in myPassword)
        secureString.AppendChar(c);
    PSCredential credential = new PSCredential(IdSenderEmail, secureString);
    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri(connectionUri), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
    connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
    Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
    PowerShell powershell = PowerShell.Create();
    PSCommand command = new PSCommand();
    command.AddCommand("Remove-DistributionGroupMember");
    command.AddParameter("Identity", IdGroupName);
    command.AddParameter("Member", IdUPN);
    command.AddParameter("Confirm", false);
    powershell.Commands = command;
    try
    {
        runspace.Open();
        powershell.Runspace = runspace;
        Collection<System.Management.Automation.PSObject> result = powershell.Invoke();
        if (powershell.Streams.Error.Count > 0 )
        {
            IdExceptionError = "Unable to removed User from the Group.  You may not have permission.";
        }
        else
        {
            IdExceptionError = "Removed User from the Group.  It can take several minutes for the change to appear here.";
        }
    }
    catch (Exception ex)
    {
        IdExceptionError = ex.ToString();
    }
    finally
    {
        runspace.Dispose();
        runspace = null;
        powershell.Dispose();
        powershell = null;
    }
}

QuestionEnclosing line for a list of points Pin
Bernhard Hiller28-Aug-18 21:36
Bernhard Hiller28-Aug-18 21:36 
AnswerRe: Enclosing line for a list of points Pin
Luc Pattyn28-Aug-18 22:15
sitebuilderLuc Pattyn28-Aug-18 22:15 
GeneralRe: Enclosing line for a list of points Pin
Peter_in_278028-Aug-18 22:17
professionalPeter_in_278028-Aug-18 22:17 
AnswerRe: Enclosing line for a list of points Pin
Peter_in_278028-Aug-18 22:16
professionalPeter_in_278028-Aug-18 22:16 
Questionsystem.drawing.image condition Pin
Xavier Escalante28-Aug-18 9:15
Xavier Escalante28-Aug-18 9:15 
AnswerRe: system.drawing.image condition Pin
Richard Deeming28-Aug-18 10:44
mveRichard Deeming28-Aug-18 10:44 
GeneralRe: system.drawing.image condition Pin
Xavier Escalante31-Aug-18 6:13
Xavier Escalante31-Aug-18 6:13 
QuestionDetect Router IP Address Change Pin
Kevin Marois28-Aug-18 7:25
professionalKevin Marois28-Aug-18 7:25 
AnswerRe: Detect Router IP Address Change Pin
Dave Kreskowiak28-Aug-18 7:40
mveDave Kreskowiak28-Aug-18 7:40 
GeneralRe: Detect Router IP Address Change Pin
Kevin Marois28-Aug-18 8:24
professionalKevin Marois28-Aug-18 8:24 
AnswerRe: Detect Router IP Address Change Pin
OriginalGriff28-Aug-18 8:07
mveOriginalGriff28-Aug-18 8:07 
GeneralRe: Detect Router IP Address Change Pin
Kevin Marois28-Aug-18 8:24
professionalKevin Marois28-Aug-18 8:24 
GeneralCall WebApi from MVC application and pass the value to a model class Pin
Member 1396461028-Aug-18 3:55
Member 1396461028-Aug-18 3:55 
GeneralRe: Call WebApi from MVC application and pass the value to a model class Pin
Simon_Whale28-Aug-18 4:43
Simon_Whale28-Aug-18 4:43 
QuestionHow to parse certain values from an invisible cmdline Pin
wesley994626-Aug-18 5:08
wesley994626-Aug-18 5:08 
AnswerRe: How to parse certain values from an invisible cmdline Pin
Mycroft Holmes26-Aug-18 13:14
professionalMycroft Holmes26-Aug-18 13:14 
GeneralRe: How to parse certain values from an invisible cmdline Pin
wesley994626-Aug-18 13:37
wesley994626-Aug-18 13:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.