Пример #1
0
        internal string GetEcpRoot(bool useWIA, string targetServerFqdn)
        {
            MonadConnection connection = new MonadConnection("pooled=false");

            using (new OpenConnection(connection))
            {
                string str = Path.Combine(ConfigurationContext.Setup.BinPath, "ConnectFunctions.ps1");
                using (MonadCommand monadCommand = new LoggableMonadCommand(". '" + str + "'", connection))
                {
                    monadCommand.CommandType = CommandType.Text;
                    monadCommand.ExecuteNonQuery();
                }
                string cmdText = "Discover-EcpVirtualDirectoryForEmc";
                using (MonadCommand monadCommand2 = new LoggableMonadCommand(cmdText, connection))
                {
                    monadCommand2.CommandType = CommandType.StoredProcedure;
                    monadCommand2.Parameters.Add(new MonadParameter("CurrentVersion", new ServerVersion(ConfigurationContext.Setup.InstalledVersion.Major, ConfigurationContext.Setup.InstalledVersion.Minor, ConfigurationContext.Setup.InstalledVersion.Build, ConfigurationContext.Setup.InstalledVersion.Revision)));
                    monadCommand2.Parameters.Add(new MonadParameter("UseWIA", useWIA));
                    if (!string.IsNullOrEmpty(targetServerFqdn))
                    {
                        monadCommand2.Parameters.Add(new MonadParameter("TargetServerFqdn", targetServerFqdn));
                    }
                    object[] array = monadCommand2.Execute();
                    if (array.Length > 0)
                    {
                        return((string)array[0]);
                    }
                }
            }
            return(null);
        }
        private static Fqdn DiscoverExchangeServer()
        {
            string fqdn = null;

            using (new OpenConnection(PSConnectionInfoSingleton.connection))
            {
                string str = Path.Combine(ConfigurationContext.Setup.BinPath, "ConnectFunctions.ps1");
                using (MonadCommand monadCommand = new LoggableMonadCommand(". '" + str + "'", PSConnectionInfoSingleton.connection))
                {
                    monadCommand.CommandType = CommandType.Text;
                    monadCommand.ExecuteNonQuery();
                }
                using (MonadCommand monadCommand2 = new LoggableMonadCommand("Discover-ExchangeServer", PSConnectionInfoSingleton.connection))
                {
                    monadCommand2.CommandType = CommandType.StoredProcedure;
                    monadCommand2.Parameters.Add(new MonadParameter("UseWIA", true));
                    monadCommand2.Parameters.Add(new MonadParameter("SuppressError", true));
                    monadCommand2.Parameters.Add(new MonadParameter("CurrentVersion", ServerVersion.InstalledVersion));
                    object[] array = monadCommand2.Execute();
                    if (array == null || array.Length <= 0)
                    {
                        throw new CmdletInvocationException(Strings.FailedToAutoDiscoverExchangeServer);
                    }
                    fqdn = (array[0] as string);
                }
            }
            return(new Fqdn(fqdn));
        }