Пример #1
0
        public static void UpdateApplicationPoolPasswords(string username, string password)
        {
            using (var svc = new IisManagementService())
            {
                var lst = svc.GetApplicationPoolCredentials();

                foreach (var ap in lst)
                {
                    svc.ChangeCredentials(username, password, ap.ApplicationPoolName);
                }
            }
        }
Пример #2
0
        public static void PrintOutApplicationPools()
        {
            try
            {
                using (var svc = new IisManagementService())
                {
                    var lst = svc.GetApplicationPoolCredentials();

                    const string s0 = "App Pool";
                    const string s1 = "Username";
                    const string s2 = "Password";

                    var c0 = TakeLargerNumber(lst.Max(x => x.ApplicationPoolName.Length), s0);
                    var c1 = TakeLargerNumber(lst.Max(x => x.Username.Length), s1);
                    var c2 = TakeLargerNumber(lst.Max(x => x.Password.Length), s2);

                    Console.BackgroundColor = ConsoleColor.DarkGray;
                    Console.ForegroundColor = ConsoleColor.Cyan;

                    PrintRow(c0, c1, c2, s0, s1, s2);

                    Console.ForegroundColor = ConsoleColor.Black;

                    for (var i = 0; i < lst.Count; i++)
                    {
                        var c = lst[i];

                        Console.BackgroundColor = i % 2 == 0 ? ConsoleColor.White : ConsoleColor.Gray;

                        PrintRow(c0, c1, c2, c);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }