none
C# Enable-OutlookAnywhere RRS feed

  • Question

  • Hi everyone,

    I hope someone in this forum can answer my pretty basic question around C#

    I want to Enable OutlookAnywhere using C# managed code and using the parameter for "IISAuthenticationMethods"
    But I'm not sure how this should be written since it's a "Microsoft.Exchange.Data.MultiValuedProperty" type

    I want to specify the IISAuthenticationMethods to use both Basic and Ntlm

    I'm using the code below:

    using (PowerShell powershell = PowerShell.Create())
                    {
                            powershell.AddCommand("Enable-OutlookAnywhere");
                            powershell.AddParameter("Server", box.Text);
                            powershell.AddParameter("ExternalHostname", txtOAExtUrl.Text);
                            powershell.AddParameter("DefaultAuthenticationMethod", "Basic");
                            powershell.AddParameter("SSLOffloading", false);
                            powershell.AddParameter("IISAuthenticationMethods", "Basic,Ntlm");

    }

    Source link for the command:

    http://technet.microsoft.com/en-us/library/bb124993.aspx

    Thanks in advance


    Jonas Andersson | Microsoft Community Contributor Award 2011 & 2012 | MCITP: EMA 2007/2010 | Blog: http://www.testlabs.se/blog | Follow me on twitter: jonand82


    Wednesday, April 11, 2012 7:55 PM

All replies

  • You should be able to use something like

                Command saSetOA = new Command("Set-OutlookAnywhere");
                saSetOA.Parameters.Add("Identity", "EX2010DEV\\Rpc (Default Web Site)");
                System.Collections.ArrayList al = new ArrayList();
                al.Add("Basic");
                al.Add("NTLM");
                saSetOA.Parameters.Add("IISAuthenticationMethods", al);
                Pipeline plPileLine = runspace.CreatePipeline();
                plPileLine.Commands.Add(saSetOA);
                Collection<PSObject> RsResultsresults = plPileLine.Invoke();
    Cheers
    Glen
    Thursday, April 12, 2012 6:27 AM
  • Thanks Glen,

    I will try this and report back


    Jonas Andersson | Microsoft Community Contributor Award 2011 & 2012 | MCITP: EMA 2007/2010 | Blog: http://www.testlabs.se/blog | Follow me on twitter: jonand82

    Thursday, April 12, 2012 12:32 PM
  • It seems like I need to use the ICollection, maybe you could post a sample for me?

    Found it at this blog post

    http://blogs.technet.com/b/evand/archive/2008/04/01/using-c-to-get-to-multivaluedproperty.aspx


    Jonas Andersson | Microsoft Community Contributor Award 2011 & 2012 | MCITP: EMA 2007/2010 | Blog: http://www.testlabs.se/blog | Follow me on twitter: jonand82

    Thursday, April 12, 2012 2:34 PM
  • You can try something really generic like

                    Command smCASMailbox = new Command("set-CasMailbox");
                    smCASMailbox.Parameters.Add("Identity", "gscales@domainblah.onmicrosoft.com");
                    Collection<PSObject> NewParameter = new Collection<PSObject>();
                    NewParameter.Add(new PSObject("121212"));
                    NewParameter.Add(new PSObject("122334"));
                    smCASMailbox.Parameters.Add("ActiveSyncBlockedDeviceIDs", NewParameter);
                    plPileLine.Commands.Add(smCASMailbox);
                    plPileLine.Invoke();
    Cheers
    Glen
    Friday, April 13, 2012 6:03 AM
  • Thanks for your input Glen

    I ended up with using the parameter "ClientAuthenticationMethod" instead of "DefaultAuthenticationMethod" and "IISAuthenticationMethods" since it was actually doing the same thing I was looking for

    If anyone needs the code I ended up using it was:

    powershell.AddCommand("Enable-OutlookAnywhere");
    powershell.AddParameter("Server", box.Text);
    powershell.AddParameter("ExternalHostname", txtOAExtUrl.Text);
    powershell.AddParameter("ClientAuthenticationMethod", "Basic");
    powershell.AddParameter("SSLOffloading", false);


    Jonas Andersson | Microsoft Community Contributor Award 2011 & 2012 | MCITP: EMA 2007/2010 | Blog: http://www.testlabs.se/blog | Follow me on twitter: jonand82


    Saturday, April 14, 2012 10:10 AM