public string Get(string username, string password)
        {
            try
            {
                StringBuilder stb = new StringBuilder();
                var(errS1, resultS1) = RemoteExchangePowerShellScenarios.SimpleExO(username, password);
                stb.AppendLine($"Call#1, Errors: {errS1}, Result: {resultS1}");

                var(errS2, resultS2) = RemoteExchangePowerShellScenarios.WSManConnectToExO(username, password);
                stb.AppendLine($"Call#1, Errors: {errS2}, Result: {resultS2}");

                return(stb.ToString());
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Ejemplo n.º 2
0
        // https://www.nuget.org/packages/Microsoft.PowerShell.SDK/
        //
        // Official documentation https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell
        // SO https://stackoverflow.com/questions/39141914/running-powershell-from-net-core
        //
        static void Main(string[] args)
        {
            var(errVT, resultVT) = PowerShellVersionTableScenario.OutputVersionTable();
            Console.WriteLine($"Version table, Errors: {errVT}{Environment.NewLine}{resultVT}");

            Console.WriteLine("Exchange scenarios, please provide an admin user account");
            Console.Write("Admin user: "******"Password: "******"Call#1, Errors: {errS1}, Result: {resultS1}");

            var(errS2, resultS2) = RemoteExchangePowerShellScenarios.WSManConnectToExO(admin, pass);
            Console.WriteLine($"Call#1, Errors: {errS2}, Result: {resultS2}");

            Console.Read();
        }