Compare commits
11 Commits
6dddb09223
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
77d86a92e2
|
|||
|
c04600b7ba
|
|||
|
c06206c4f0
|
|||
|
a5a0e6b8dc
|
|||
|
be74f191c7
|
|||
|
ac97396686
|
|||
|
151f312883
|
|||
|
342552eef6
|
|||
|
fdc1450c3e
|
|||
|
57c1fd0095
|
|||
|
c5f59da80f
|
32
CHANGELOG.md
32
CHANGELOG.md
@@ -1,3 +1,33 @@
|
|||||||
|
## 05-12-2025
|
||||||
|
* Fix: Исправлено исключение возникающее при попытке открыть CUPS компьютера без сети
|
||||||
|
|
||||||
|
## 14-10-2025
|
||||||
|
* Fix: Обновлено отображение состояния учетной записи при просмотре информации
|
||||||
|
* Refactor: Переписана функция открытия CUPS удаленного ПК (так как пропала возможность открыть страницу по доменному имени компьютера)
|
||||||
|
|
||||||
|
## 21-05-2025
|
||||||
|
* Feat: Добавлено открытие файловой системы удаленного ПК (только для Windows)
|
||||||
|
|
||||||
|
## 01-05-2025
|
||||||
|
* Feat: Добавлено разделение по рабочим местам при массовой смене пароля
|
||||||
|
|
||||||
|
## 06-03-2025 (Релиз 1.0)
|
||||||
|
* Refactor: Замена Console на AnsiConsole
|
||||||
|
* Refactor: Изменена реализация ввода паролей
|
||||||
|
* Refactor: Замена Regex.Match на Regex.IsMatch
|
||||||
|
* Feat: Массовая смена пароля 802.1x
|
||||||
|
|
||||||
|
## 02-03-2025
|
||||||
|
* Refactor: Изменены области видимости методов
|
||||||
|
* Refactor: Переписано основное меню
|
||||||
|
* Refactor: Обновлен settings.json
|
||||||
|
* Feat: Добавлен новый пакет: Spectre.Console
|
||||||
|
* Feat: Добавлено отображение текущей функции при переходе
|
||||||
|
|
||||||
|
## 18-02-2025
|
||||||
|
* Refactor: Обновлен settings.json
|
||||||
|
* Feat: массовая перезагрузка ПК посредством запуска программы с определенным параметром (остался вопрос с работой с авторизацией)
|
||||||
|
|
||||||
## 17-02-2025
|
## 17-02-2025
|
||||||
* Fix: Исправлен баг с проверкой ввода на пустоту или пробелы
|
* Fix: Исправлен баг с проверкой ввода на пустоту или пробелы
|
||||||
* Refactor: Изменены регулярные выражения для форматирования имени ПК
|
* Refactor: Изменены регулярные выражения для форматирования имени ПК
|
||||||
@@ -18,7 +48,7 @@
|
|||||||
|
|
||||||
## 08-10-2024
|
## 08-10-2024
|
||||||
* Fix: Убраны проверки при вводе в ShowDomainUserInfo
|
* Fix: Убраны проверки при вводе в ShowDomainUserInfo
|
||||||
* Fix: Убрана очистка окна при ввода команды для выполнения в ExecuteCommandViaSSH
|
* Fix: Убрана очистка окна при вводе команды для выполнения в ExecuteCommandViaSSH
|
||||||
* Fix: Исправлен удаленный перезапуск ПК на Windows
|
* Fix: Исправлен удаленный перезапуск ПК на Windows
|
||||||
* Refactor: Небольшое изменение поведения ShowDomainUserInfo
|
* Refactor: Небольшое изменение поведения ShowDomainUserInfo
|
||||||
* Feat: Изменен заголовок окна программы на имя проекта
|
* Feat: Изменен заголовок окна программы на имя проекта
|
||||||
|
|||||||
421
Program.cs
421
Program.cs
@@ -1,5 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Renci.SshNet;
|
using Renci.SshNet;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -22,7 +23,7 @@ namespace domain_utility
|
|||||||
static readonly string regularDateTime = @"(\d+[.]\d+[.]\d+[ ]\d+[:]\d+[:]\d+)";
|
static readonly string regularDateTime = @"(\d+[.]\d+[.]\d+[ ]\d+[:]\d+[:]\d+)";
|
||||||
|
|
||||||
static readonly string[,] stringsToFind = new string[,] {
|
static readonly string[,] stringsToFind = new string[,] {
|
||||||
{ "Учетная запись активна", @"(Yes|No)", "Учетная запись работает: " },
|
{ "Учетная запись активна", @"(Yes|No|Блокировка)", "Учетная запись работает: " },
|
||||||
{ "Последний пароль задан", regularDateTime, "Когда был сменен пароль: " },
|
{ "Последний пароль задан", regularDateTime, "Когда был сменен пароль: " },
|
||||||
{ "Действие пароля завершается", regularDateTime, "Когда нужно менять пароль (крайний срок): "},
|
{ "Действие пароля завершается", regularDateTime, "Когда нужно менять пароль (крайний срок): "},
|
||||||
{ "Членство в глобальных группах", @"([*].+)", "Член групп:\t" }
|
{ "Членство в глобальных группах", @"([*].+)", "Член групп:\t" }
|
||||||
@@ -34,67 +35,52 @@ namespace domain_utility
|
|||||||
{ "^[rR]\\d{2,}[-]\\d{6,}[a-zA-Z]+\\d+$", "" } // R54-630300THE01
|
{ "^[rR]\\d{2,}[-]\\d{6,}[a-zA-Z]+\\d+$", "" } // R54-630300THE01
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string domain_user = string.Empty;
|
static string domain_user = string.Empty;
|
||||||
private static string domain_password = string.Empty;
|
static string domain_password = string.Empty;
|
||||||
|
|
||||||
//private static volatile bool _click_cancel = false;
|
static bool _click_cancel = false;
|
||||||
private static bool _click_cancel = false;
|
|
||||||
|
|
||||||
private static bool IsStringContainIp(string ip)
|
static bool IsStringContainIp(string ip)
|
||||||
{
|
{
|
||||||
return Regex.Match(ip, @"^(\d+[.]\d+[.]\d+[.]\d+)$").Success;
|
return Regex.IsMatch(ip, @"^(\d+[.]\d+[.]\d+[.]\d+)$");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CheckComputerName(string pcName)
|
static string CheckComputerName(string pcName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < computerNameRegex.GetLength(0); i++)
|
for (int i = 0; i < computerNameRegex.GetLength(0); i++)
|
||||||
if (Regex.Match(pcName, computerNameRegex[i, 0]).Success)
|
if (Regex.IsMatch(pcName, computerNameRegex[i, 0]))
|
||||||
return $"{computerNameRegex[i, 1]}{pcName}".ToUpper();
|
return $"{computerNameRegex[i, 1]}{pcName}".ToUpper();
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private static void InputCancelClick(object sender, ConsoleCancelEventArgs e)
|
static string InputData(string message, Action callback, bool withClear = true, bool withChecks = true)
|
||||||
//{
|
|
||||||
// //e.Cancel = true;
|
|
||||||
// _click_cancel = true;
|
|
||||||
// //Menu();
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static string InputData(string message, Action callback, bool withClear = true, bool withChecks = true)
|
|
||||||
{
|
{
|
||||||
//Console.CancelKeyPress += InputCancelClick;
|
|
||||||
//if (_click_cancel)
|
|
||||||
//{
|
|
||||||
// Console.CancelKeyPress -= InputCancelClick;
|
|
||||||
// _click_cancel = false;
|
|
||||||
// Menu();
|
|
||||||
//}
|
|
||||||
if (withClear)
|
if (withClear)
|
||||||
Console.Clear();
|
AnsiConsole.Clear();
|
||||||
Console.WriteLine(message);
|
string data = AnsiConsole.Prompt(
|
||||||
Console.Write("> ");
|
new TextPrompt<string>(message + "\n> ")
|
||||||
string data = Console.ReadLine();
|
);
|
||||||
if (string.IsNullOrWhiteSpace(data))
|
if (string.IsNullOrWhiteSpace(data))
|
||||||
return InputData(message, callback, withClear, withChecks);
|
return InputData(message, callback, withClear, withChecks);
|
||||||
data = data.Trim();
|
data = data.Trim();
|
||||||
Console.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
if (withChecks)
|
if (withChecks)
|
||||||
if (!IsStringContainIp(data))
|
if (!IsStringContainIp(data))
|
||||||
{
|
{
|
||||||
data = CheckComputerName(data);
|
data = CheckComputerName(data);
|
||||||
if (data == string.Empty)
|
if (data == string.Empty)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Имя компьютера или IP-адрес не распознаны! Попробуйте еще раз.");
|
AnsiConsole.WriteLine("Имя компьютера или IP-адрес не распознаны! Попробуйте еще раз.");
|
||||||
BackToMenu(callback);
|
BackToMenu(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BackToMenu(Action callback, bool withMessage = true)
|
static void BackToMenu(Action callback, bool withMessage = true)
|
||||||
{
|
{
|
||||||
if (withMessage)
|
if (withMessage)
|
||||||
Console.WriteLine("\nНажмите Enter чтобы продолжить, ESC чтобы вернуться на главную.");
|
AnsiConsole.WriteLine("\nНажмите Enter чтобы продолжить, ESC чтобы вернуться на главную.");
|
||||||
ConsoleKey key = Console.ReadKey(true).Key;
|
ConsoleKey key = Console.ReadKey(true).Key;
|
||||||
if (key == ConsoleKey.Enter)
|
if (key == ConsoleKey.Enter)
|
||||||
callback.Invoke();
|
callback.Invoke();
|
||||||
@@ -102,12 +88,12 @@ namespace domain_utility
|
|||||||
Menu();
|
Menu();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Нажмите Enter или ESC!");
|
AnsiConsole.WriteLine("Нажмите Enter или ESC!");
|
||||||
BackToMenu(callback, false);
|
BackToMenu(callback, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InputDomainCredentials()
|
static void InputDomainCredentials()
|
||||||
{
|
{
|
||||||
if (domain_user == string.Empty)
|
if (domain_user == string.Empty)
|
||||||
{
|
{
|
||||||
@@ -117,32 +103,13 @@ namespace domain_utility
|
|||||||
}
|
}
|
||||||
if (domain_password != string.Empty)
|
if (domain_password != string.Empty)
|
||||||
return;
|
return;
|
||||||
Console.WriteLine("Введите пароль от ТЕКУЩЕЙ учетной записи:");
|
domain_password = AnsiConsole.Prompt(
|
||||||
Console.Write("> ");
|
new TextPrompt<string>("\nВведите пароль от ТЕКУЩЕЙ учетной записи:\n> ")
|
||||||
string password = string.Empty;
|
.Secret()
|
||||||
ConsoleKeyInfo key;
|
);
|
||||||
do
|
|
||||||
{
|
|
||||||
key = Console.ReadKey(true);
|
|
||||||
if (key.Key == ConsoleKey.Backspace && password.Length > 0)
|
|
||||||
{
|
|
||||||
password = password.Substring(0, password.Length - 1);
|
|
||||||
Console.Write("\b \b");
|
|
||||||
}
|
|
||||||
else if (key.KeyChar < 32 || key.KeyChar > 126)
|
|
||||||
continue;
|
|
||||||
else if (key.Key != ConsoleKey.Backspace)
|
|
||||||
{
|
|
||||||
password += key.KeyChar;
|
|
||||||
Console.Write("*");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (key.Key != ConsoleKey.Enter);
|
|
||||||
Console.Write("\n\n");
|
|
||||||
domain_password = password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ExecuteCommandViaSSH(string remote, string commandToExecute)
|
static void ExecuteCommandViaSSH(string remote, string commandToExecute)
|
||||||
{
|
{
|
||||||
InputDomainCredentials();
|
InputDomainCredentials();
|
||||||
try
|
try
|
||||||
@@ -151,17 +118,17 @@ namespace domain_utility
|
|||||||
{
|
{
|
||||||
client.Connect();
|
client.Connect();
|
||||||
SshCommand command = client.RunCommand(commandToExecute);
|
SshCommand command = client.RunCommand(commandToExecute);
|
||||||
Console.WriteLine(command.Result);
|
AnsiConsole.WriteLine(command.Result);
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Произошла ошибка: " + ex.Message);
|
AnsiConsole.WriteLine("Произошла ошибка: " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ResetAdminPassword()
|
static void ResetAdminPassword()
|
||||||
{
|
{
|
||||||
string machineNameAndUser = WindowsIdentity.GetCurrent().Name.ToString();
|
string machineNameAndUser = WindowsIdentity.GetCurrent().Name.ToString();
|
||||||
string machineName = machineNameAndUser.Substring(0, machineNameAndUser.IndexOf('\\'));
|
string machineName = machineNameAndUser.Substring(0, machineNameAndUser.IndexOf('\\'));
|
||||||
@@ -174,11 +141,11 @@ namespace domain_utility
|
|||||||
directoryEntry.Close();
|
directoryEntry.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Пароль сброшен.");
|
AnsiConsole.WriteLine("Пароль сброшен.");
|
||||||
BackToMenu(Menu);
|
BackToMenu(Menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string PingHost(string host)
|
static string PingHost(string host)
|
||||||
{
|
{
|
||||||
string returnMessage = string.Empty;
|
string returnMessage = string.Empty;
|
||||||
PingOptions pingOptions = new PingOptions() { DontFragment = true }; // TTL = 128
|
PingOptions pingOptions = new PingOptions() { DontFragment = true }; // TTL = 128
|
||||||
@@ -226,18 +193,18 @@ namespace domain_utility
|
|||||||
return returnMessage;
|
return returnMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PingClickCancel(object sender, ConsoleCancelEventArgs e)
|
static void PingClickCancel(object sender, ConsoleCancelEventArgs e)
|
||||||
{
|
{
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
_click_cancel = true;
|
_click_cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void StartPing()
|
static void StartPing()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("ping компьютера\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
StartPing);
|
StartPing);
|
||||||
|
|
||||||
Console.WriteLine("Нажмите Ctrl + C чтобы остановить\n");
|
AnsiConsole.WriteLine("Нажмите Ctrl + C чтобы остановить\n");
|
||||||
string correctName = CheckComputerName(remote);
|
string correctName = CheckComputerName(remote);
|
||||||
if (correctName != string.Empty)
|
if (correctName != string.Empty)
|
||||||
{
|
{
|
||||||
@@ -245,23 +212,23 @@ namespace domain_utility
|
|||||||
{
|
{
|
||||||
IPAddress ip = Dns.GetHostEntry(correctName).AddressList.First(addr => addr.AddressFamily == AddressFamily.InterNetwork);
|
IPAddress ip = Dns.GetHostEntry(correctName).AddressList.First(addr => addr.AddressFamily == AddressFamily.InterNetwork);
|
||||||
remote = ip.ToString();
|
remote = ip.ToString();
|
||||||
Console.WriteLine("Обмен пакетами с {0}.main.russianpost.ru [{1}] с 32 байтами данных:", correctName, remote);
|
AnsiConsole.WriteLine("Обмен пакетами с {0}.main.russianpost.ru [{1}] с 32 байтами данных:", correctName, remote);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Компьютер не найден.");
|
AnsiConsole.WriteLine("Компьютер не найден.");
|
||||||
BackToMenu(StartPing);
|
BackToMenu(StartPing);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine("Обмен пакетами с {0} по с 32 байтами данных:", remote);
|
AnsiConsole.WriteLine("Обмен пакетами с {0} по с 32 байтами данных:", remote);
|
||||||
|
|
||||||
Console.CancelKeyPress += PingClickCancel;
|
Console.CancelKeyPress += PingClickCancel;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (_click_cancel) break;
|
if (_click_cancel) break;
|
||||||
Console.WriteLine(PingHost(remote));
|
AnsiConsole.WriteLine(PingHost(remote));
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
Console.CancelKeyPress -= PingClickCancel;
|
Console.CancelKeyPress -= PingClickCancel;
|
||||||
@@ -270,9 +237,9 @@ namespace domain_utility
|
|||||||
BackToMenu(StartPing);
|
BackToMenu(StartPing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void StartRDPConnection()
|
static void StartRDPConnection()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("удаленный доступ к компьютеру\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
StartRDPConnection);
|
StartRDPConnection);
|
||||||
|
|
||||||
remote = $"/v:{remote} /f";
|
remote = $"/v:{remote} /f";
|
||||||
@@ -280,14 +247,14 @@ namespace domain_utility
|
|||||||
proc.StartInfo = new ProcessStartInfo("mstsc", remote);
|
proc.StartInfo = new ProcessStartInfo("mstsc", remote);
|
||||||
proc.Start();
|
proc.Start();
|
||||||
|
|
||||||
Console.WriteLine("Подключение открыто.");
|
AnsiConsole.WriteLine("Подключение открыто.");
|
||||||
|
|
||||||
BackToMenu(StartRDPConnection);
|
BackToMenu(StartRDPConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowDomainUserInfo()
|
static void ShowDomainUserInfo()
|
||||||
{
|
{
|
||||||
string username = InputData("\nВведите имя пользователя (пр. 'lev.rusanov'): ", ShowDomainUserInfo, withChecks: false);
|
string username = InputData("посмотреть информацию о пользователе\n\nВведите имя пользователя (пр. 'lev.rusanov'): ", ShowDomainUserInfo, withChecks: false);
|
||||||
|
|
||||||
username = $"user {username} /domain";
|
username = $"user {username} /domain";
|
||||||
|
|
||||||
@@ -315,7 +282,7 @@ namespace domain_utility
|
|||||||
regex = Regex.Match(strArr[i], stringsToFind[j, 1]);
|
regex = Regex.Match(strArr[i], stringsToFind[j, 1]);
|
||||||
if (regex.Success)
|
if (regex.Success)
|
||||||
{
|
{
|
||||||
Console.WriteLine(stringsToFind[j, 2] + regex.Value);
|
AnsiConsole.WriteLine(stringsToFind[j, 2] + regex.Value);
|
||||||
if (j == 3)
|
if (j == 3)
|
||||||
{
|
{
|
||||||
groupsFlag = true;
|
groupsFlag = true;
|
||||||
@@ -327,7 +294,7 @@ namespace domain_utility
|
|||||||
{
|
{
|
||||||
regex = Regex.Match(strArr[i], stringsToFind[j, 1]);
|
regex = Regex.Match(strArr[i], stringsToFind[j, 1]);
|
||||||
if (regex.Success)
|
if (regex.Success)
|
||||||
Console.WriteLine("\t\t" + regex.Value);
|
AnsiConsole.WriteLine("\t\t" + regex.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,9 +303,9 @@ namespace domain_utility
|
|||||||
BackToMenu(ShowDomainUserInfo);
|
BackToMenu(ShowDomainUserInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowComputerBootupTime()
|
static void ShowComputerBootupTime()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("посмотреть дату последней загрузки компьютера\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
ShowComputerBootupTime);
|
ShowComputerBootupTime);
|
||||||
|
|
||||||
ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\cimv2", remote));
|
ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\cimv2", remote));
|
||||||
@@ -349,20 +316,20 @@ namespace domain_utility
|
|||||||
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
|
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
|
||||||
var firstResult = searcher.Get().OfType<ManagementObject>().First()["LastBootUpTime"];
|
var firstResult = searcher.Get().OfType<ManagementObject>().First()["LastBootUpTime"];
|
||||||
DateTime lastBootUp = ManagementDateTimeConverter.ToDateTime(firstResult.ToString());
|
DateTime lastBootUp = ManagementDateTimeConverter.ToDateTime(firstResult.ToString());
|
||||||
Console.WriteLine("Дата последней загрузки: " + lastBootUp);
|
AnsiConsole.WriteLine("Дата последней загрузки: " + lastBootUp);
|
||||||
Console.WriteLine("Время работы (д:ч:м:с): " + (DateTime.Now.ToUniversalTime() - lastBootUp.ToUniversalTime()).ToString(@"d\:hh\:mm\:ss"));
|
AnsiConsole.WriteLine("Время работы (д:ч:м:с): " + (DateTime.Now.ToUniversalTime() - lastBootUp.ToUniversalTime()).ToString(@"d\:hh\:mm\:ss"));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Произошла ошибка. Попробуйте еще раз.");
|
AnsiConsole.WriteLine("Произошла ошибка. Попробуйте еще раз.");
|
||||||
}
|
}
|
||||||
|
|
||||||
BackToMenu(ShowComputerBootupTime);
|
BackToMenu(ShowComputerBootupTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RemoteRebootWindows()
|
static void RemoteRebootWindows()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("удаленная перезагрузка компьютера\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
RemoteRebootWindows);
|
RemoteRebootWindows);
|
||||||
|
|
||||||
remote = $"/m \\\\{remote} /r /f /t 180 /c \"Через 3 минуты будет произведена перезагрузка ПК!\"";
|
remote = $"/m \\\\{remote} /r /f /t 180 /c \"Через 3 минуты будет произведена перезагрузка ПК!\"";
|
||||||
@@ -370,64 +337,81 @@ namespace domain_utility
|
|||||||
proc.StartInfo = new ProcessStartInfo("shutdown", remote);
|
proc.StartInfo = new ProcessStartInfo("shutdown", remote);
|
||||||
proc.Start();
|
proc.Start();
|
||||||
|
|
||||||
Console.WriteLine("Команда перезагрузки отправлена.");
|
AnsiConsole.WriteLine("Команда перезагрузки отправлена.");
|
||||||
|
|
||||||
BackToMenu(RemoteRebootWindows);
|
BackToMenu(RemoteRebootWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OpenComputerCups()
|
static void OpenComputerCups()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("открыть CUPS выбранного компьютера (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
OpenComputerCups);
|
OpenComputerCups);
|
||||||
|
|
||||||
Process.Start($"https://{remote}:631/printers");
|
if (CheckComputerName(remote) != string.Empty)
|
||||||
|
{
|
||||||
|
string pc_name = remote;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
remote = Dns.GetHostEntry(remote).AddressList.First(addr => addr.AddressFamily == AddressFamily.InterNetwork).ToString();
|
||||||
|
if (!IsStringContainIp(pc_name))
|
||||||
|
AnsiConsole.WriteLine($"CUPS {pc_name} ({remote}) открыт.");
|
||||||
|
else
|
||||||
|
AnsiConsole.WriteLine($"CUPS {remote} открыт.");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
AnsiConsole.WriteLine("Компьютер не найден.");
|
||||||
|
BackToMenu(OpenComputerCups);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine($"CUPS {remote} открыт.");
|
Process.Start($"https://{remote}:631/printers");
|
||||||
|
|
||||||
BackToMenu(OpenComputerCups);
|
BackToMenu(OpenComputerCups);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ExecuteCustomCommandViaSSH()
|
static void ExecuteCustomCommandViaSSH()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("выполнить команду через SSH (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
ExecuteCustomCommandViaSSH);
|
ExecuteCustomCommandViaSSH);
|
||||||
|
|
||||||
string commandToExecute = InputData("Введите команду для выполнения:", ExecuteCustomCommandViaSSH, withClear: false, withChecks: false);
|
string commandToExecute = InputData("Введите команду для выполнения:", ExecuteCustomCommandViaSSH, withClear: false, withChecks: false);
|
||||||
|
|
||||||
ExecuteCommandViaSSH(remote, commandToExecute);
|
ExecuteCommandViaSSH(remote, commandToExecute);
|
||||||
|
|
||||||
Console.WriteLine("Команда выполнена.");
|
AnsiConsole.WriteLine("Команда выполнена.");
|
||||||
|
|
||||||
BackToMenu(ExecuteCustomCommandViaSSH);
|
BackToMenu(ExecuteCustomCommandViaSSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FixConky()
|
static void FixConky()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("изменить время обновления conky с 0.5 на 300 (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
FixConky);
|
FixConky);
|
||||||
|
|
||||||
ExecuteCommandViaSSH(remote, "sudo sed -i 's/update_interval = 0.5,/update_interval = 300,/' /etc/conky/conky.conf");
|
ExecuteCommandViaSSH(remote, "sudo sed -i 's/update_interval = 0.5,/update_interval = 300,/' /etc/conky/conky.conf");
|
||||||
|
|
||||||
Console.WriteLine("Команда исправления Conky отправлена.");
|
AnsiConsole.WriteLine("Команда исправления Conky отправлена.");
|
||||||
|
|
||||||
BackToMenu(FixConky);
|
BackToMenu(FixConky);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RemoteRebootLinux()
|
static void RemoteRebootLinux()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("удаленная перезагрузка компьютера (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
RemoteRebootLinux);
|
RemoteRebootLinux);
|
||||||
|
|
||||||
ExecuteCommandViaSSH(remote, "sudo shutdown -r +3 \"Через 3 минуты будет произведена перезагрузка ПК!\"");
|
ExecuteCommandViaSSH(remote, "sudo shutdown -r +3 \"Через 3 минуты будет произведена перезагрузка ПК!\"");
|
||||||
|
|
||||||
Console.WriteLine("Команда перезагрузки отправлена.");
|
AnsiConsole.WriteLine("Команда перезагрузки отправлена.");
|
||||||
|
|
||||||
BackToMenu(RemoteRebootLinux);
|
BackToMenu(RemoteRebootLinux);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowLinuxComputerBootupTime()
|
static void ShowLinuxComputerBootupTime()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("посмотреть время работы компьютера (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
ShowLinuxComputerBootupTime);
|
ShowLinuxComputerBootupTime);
|
||||||
|
|
||||||
ExecuteCommandViaSSH(remote, "uptime");
|
ExecuteCommandViaSSH(remote, "uptime");
|
||||||
@@ -435,11 +419,11 @@ namespace domain_utility
|
|||||||
BackToMenu(ShowLinuxComputerBootupTime);
|
BackToMenu(ShowLinuxComputerBootupTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ChangeRemote802Password()
|
static void ChangeRemote802Password()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04')\nall - для массового изменения",
|
string remote = InputData("сменить пароль для 802.1x (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04')\nall - для массового изменения",
|
||||||
ChangeRemote802Password, withChecks: false);
|
ChangeRemote802Password, withChecks: false);
|
||||||
remote = remote.ToLower();
|
remote = remote.Trim().ToLower();
|
||||||
if (remote != "all")
|
if (remote != "all")
|
||||||
{
|
{
|
||||||
if (!IsStringContainIp(remote))
|
if (!IsStringContainIp(remote))
|
||||||
@@ -450,146 +434,187 @@ namespace domain_utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string new802password = InputData("\nВведите новый пароль от УЗ:", ChangeRemote802Password, withClear: false, withChecks: false);
|
string new802password = AnsiConsole.Prompt(
|
||||||
|
new TextPrompt<string>("\nВведите новый пароль от УЗ:\n> ")
|
||||||
|
.Secret()
|
||||||
|
);
|
||||||
|
|
||||||
if (remote == "all")
|
if (remote == "all")
|
||||||
{
|
{
|
||||||
//InputDomainCredentials();
|
string armListKey = AnsiConsole.Prompt(
|
||||||
// load json file with pc names
|
new TextPrompt<string>("Введите УЗ на которой нужно сменить пароль")
|
||||||
//string[] pc_names = { "it01", "it02" };
|
.AddChoices(new string[] { "OBR", "PIS", "OBM", "MMP" })
|
||||||
//string pc_name;
|
);
|
||||||
//foreach (var item in pc_names)
|
InputDomainCredentials();
|
||||||
//{
|
string path = Path.Combine(Environment.CurrentDirectory, "settings.json");
|
||||||
// pc_name = CheckComputerName(item);
|
if (!File.Exists(path))
|
||||||
// if (pc_name == string.Empty)
|
{
|
||||||
// continue;
|
AnsiConsole.WriteLine("Файл с настройками не найден!");
|
||||||
// try
|
BackToMenu(ChangeRemote802Password);
|
||||||
// {
|
}
|
||||||
// using (SshClient client = new SshClient(pc_name, domain_user, domain_password))
|
JsonFile data = JsonConvert.DeserializeObject<JsonFile>(File.ReadAllText(path));
|
||||||
// {
|
string unitKey;
|
||||||
// client.Connect();
|
int sleep_time = data.sleep_time;
|
||||||
// SshCommand command = client.RunCommand($"sudo sed -i 's/password=.\\+/password={new802password}/' /etc/NetworkManager/system-connections/Проводное\\ подключение\\ 1.nmconnection");
|
foreach (KeyValuePair<string, List<int>> unit in data.arm_list)
|
||||||
// Console.WriteLine(command.Result);
|
{
|
||||||
// command = client.RunCommand("sudo nmcli connection reload");
|
unitKey = unit.Key;
|
||||||
// Console.WriteLine(command.Result);
|
if (unitKey != armListKey)
|
||||||
// command.Dispose();
|
continue;
|
||||||
// client.Disconnect();
|
foreach (int position in unit.Value)
|
||||||
// }
|
{
|
||||||
// Console.WriteLine(pc_name + ": ");
|
remote = CheckComputerName($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}");
|
||||||
// }
|
if (remote == string.Empty)
|
||||||
// catch (Exception ex)
|
{
|
||||||
// {
|
AnsiConsole.WriteLine($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}: имя ПК не распознано.");
|
||||||
// Console.WriteLine(pc_name + ": " + ex.Message);
|
continue;
|
||||||
// }
|
}
|
||||||
//}
|
try
|
||||||
Console.WriteLine("Пока не реализовано :(");
|
{
|
||||||
|
using (SshClient client = new SshClient(remote, domain_user, domain_password))
|
||||||
|
{
|
||||||
|
client.Connect();
|
||||||
|
SshCommand command = client.RunCommand($"sudo sed -i 's/password=.\\+/password={new802password}/' /etc/NetworkManager/system-connections/Проводное\\ подключение\\ 1.nmconnection");
|
||||||
|
//AnsiConsole.WriteLine(command.Result);
|
||||||
|
command = client.RunCommand("sudo nmcli connection reload");
|
||||||
|
//AnsiConsole.WriteLine(command.Result);
|
||||||
|
command.Dispose();
|
||||||
|
client.Disconnect();
|
||||||
|
}
|
||||||
|
AnsiConsole.WriteLine(remote + ": ");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AnsiConsole.WriteLine(remote + ": " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ExecuteCommandViaSSH(remote, $"sudo sed -i 's/^password=.\\+/password={new802password}/' /etc/NetworkManager/system-connections/Проводное\\ подключение\\ 1.nmconnection && sudo nmcli connection reload");
|
ExecuteCommandViaSSH(remote, $"sudo sed -i 's/^password=.\\+/password={new802password}/' /etc/NetworkManager/system-connections/Проводное\\ подключение\\ 1.nmconnection && sudo nmcli connection reload");
|
||||||
Console.WriteLine("Команда отправлена.");
|
AnsiConsole.WriteLine("Команда отправлена.");
|
||||||
}
|
}
|
||||||
|
|
||||||
BackToMenu(ChangeRemote802Password);
|
BackToMenu(ChangeRemote802Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DisableKdeWallet()
|
static void DisableKdeWallet()
|
||||||
{
|
{
|
||||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
string remote = InputData("отключить KDE кошелек (Linux)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
DisableKdeWallet);
|
DisableKdeWallet);
|
||||||
|
|
||||||
ExecuteCommandViaSSH(remote, "sudo sed -i 's/^Exec=/#Exec=/' /usr/share/dbus-1/services/org.kde.kwalletd5.service");
|
ExecuteCommandViaSSH(remote, "sudo sed -i 's/^Exec=/#Exec=/' /usr/share/dbus-1/services/org.kde.kwalletd5.service");
|
||||||
|
|
||||||
Console.WriteLine("Команда отключения кошелька отправлена.");
|
AnsiConsole.WriteLine("Команда отключения кошелька отправлена.");
|
||||||
|
|
||||||
BackToMenu(DisableKdeWallet);
|
BackToMenu(DisableKdeWallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly string[] menuList = {
|
static void OpenRemoteFilesystemWindows()
|
||||||
//"630300 - сброс пароля локального администратора (только Windows)", // ResetAdminPassword
|
{
|
||||||
"Выберите действие:",
|
string remote = InputData("открыть файловую систему удаленного ПК (Windows)\n\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04'):",
|
||||||
"1 - ping компьютера", // StartPing
|
OpenRemoteFilesystemWindows);
|
||||||
"2 - удаленно подключиться к компьютеру", // StartRDPConnection
|
|
||||||
"\nWindows:",
|
remote = $"\\\\{remote}\\c$";
|
||||||
"3 - посмотреть информацию о пользователе", // ShowDomainUserInfo
|
Process proc = new Process();
|
||||||
"4 - посмотреть дату последней загрузки компьютера", // ShowComputerBootupTime
|
proc.StartInfo = new ProcessStartInfo("explorer", remote);
|
||||||
"5 - удаленная перезагрузка компьютера", // RemoteRebootWindows
|
proc.Start();
|
||||||
"\nLinux:",
|
|
||||||
"6 - открыть CUPS выбранного компьютера", // OpenComputerCups
|
AnsiConsole.WriteLine("Файловая система открыта.");
|
||||||
"7 - выполнить команду через SSH", // ExecuteCustomCommandViaSSH
|
|
||||||
"8 - изменить время обновления conky с 0.5 на 300", // FixConky
|
BackToMenu(OpenRemoteFilesystemWindows);
|
||||||
"9 - удаленная перезагрузка компьютера", // RemoteRebootLinux
|
}
|
||||||
"10 - посмотреть время работы компьютера", // ShowLinuxComputerBootupTime
|
|
||||||
"11 - сменить пароль для 802.1x", // ChangeRemote802Password
|
private class MenuItem
|
||||||
"12 - отключить KDE кошелек", // DisableKdeWallet
|
{
|
||||||
|
public string Name { get; }
|
||||||
|
public Action Executor { get; }
|
||||||
|
|
||||||
|
public MenuItem(string _name, Action _executor)
|
||||||
|
{
|
||||||
|
Name = _name;
|
||||||
|
Executor = _executor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly MenuItem[] availableOptions = new[]
|
||||||
|
{
|
||||||
|
new MenuItem("ping компьютера", () => StartPing()),
|
||||||
|
new MenuItem("удаленный доступ к компьютеру", () => StartRDPConnection()),
|
||||||
|
new MenuItem("посмотреть информацию о пользователе", () => ShowDomainUserInfo()),
|
||||||
|
new MenuItem("посмотреть дату последней загрузки компьютера", () => ShowComputerBootupTime()),
|
||||||
|
new MenuItem("удаленная перезагрузка компьютера", () => RemoteRebootWindows()),
|
||||||
|
new MenuItem("открыть CUPS выбранного компьютера (Linux)", () => OpenComputerCups()),
|
||||||
|
new MenuItem("выполнить команду через SSH (Linux)", () => ExecuteCustomCommandViaSSH()),
|
||||||
|
new MenuItem("изменить время обновления conky с 0.5 на 300 (Linux)", () => FixConky()),
|
||||||
|
new MenuItem("удаленная перезагрузка компьютера (Linux)", () => RemoteRebootLinux()),
|
||||||
|
new MenuItem("посмотреть время работы компьютера (Linux)", () => ShowLinuxComputerBootupTime()),
|
||||||
|
new MenuItem("сменить пароль для 802.1x (Linux)", () => ChangeRemote802Password()),
|
||||||
|
new MenuItem("отключить KDE кошелек (Linux)", () => DisableKdeWallet()),
|
||||||
|
new MenuItem("открыть файловую систему удаленного ПК (Windows)", () => OpenRemoteFilesystemWindows()),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static void Menu()
|
static void Menu()
|
||||||
{
|
{
|
||||||
Console.Clear();
|
AnsiConsole.Clear();
|
||||||
foreach (string item in menuList) // for (int i = 0; i < menuList.Length; i++)
|
MenuItem choice = AnsiConsole.Prompt(
|
||||||
Console.WriteLine(item); // Console.WriteLine(menuList[i]);
|
new SelectionPrompt<MenuItem>()
|
||||||
int choice;
|
.Title("Выберите действие:")
|
||||||
Console.Write("\n> ");
|
.PageSize(15)
|
||||||
while (!int.TryParse(Console.ReadLine(), out choice))
|
//.MoreChoicesText("[grey](Move up and down to reveal more fruits)[/]")
|
||||||
{
|
.UseConverter(i => i.Name)
|
||||||
Console.WriteLine("Введите цифру!");
|
.AddChoices(availableOptions)
|
||||||
Console.Write("> ");
|
);
|
||||||
}
|
choice.Executor();
|
||||||
switch (choice)
|
|
||||||
{
|
|
||||||
case 1: StartPing(); break;
|
|
||||||
case 2: StartRDPConnection(); break;
|
|
||||||
case 3: ShowDomainUserInfo(); break;
|
|
||||||
case 4: ShowComputerBootupTime(); break;
|
|
||||||
case 5: RemoteRebootWindows(); break;
|
|
||||||
case 6: OpenComputerCups(); break;
|
|
||||||
case 7: ExecuteCustomCommandViaSSH(); break;
|
|
||||||
case 8: FixConky(); break;
|
|
||||||
case 9: RemoteRebootLinux(); break;
|
|
||||||
case 10: ShowLinuxComputerBootupTime(); break;
|
|
||||||
case 11: ChangeRemote802Password(); break;
|
|
||||||
case 12: DisableKdeWallet(); break;
|
|
||||||
case 630300: ResetAdminPassword(); break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
Menu();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void StartRestartComputers()
|
class JsonFile
|
||||||
|
{
|
||||||
|
public int sleep_time = 0;
|
||||||
|
public int restart_time = 0;
|
||||||
|
public string message = "";
|
||||||
|
public Dictionary<string, List<int>> arm_list = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StartRestartComputers()
|
||||||
{
|
{
|
||||||
string path = Path.Combine(Environment.CurrentDirectory, "settings.json");
|
string path = Path.Combine(Environment.CurrentDirectory, "settings.json");
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Файл с настройками не найден!");
|
AnsiConsole.WriteLine("Файл с настройками не найден!");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(path));
|
JsonFile data = JsonConvert.DeserializeObject<JsonFile>(File.ReadAllText(path));
|
||||||
string remote;
|
string remote, unitKey;
|
||||||
int sleep_time = Convert.ToInt32(data.sleep_time);
|
int sleep_time = data.sleep_time;
|
||||||
foreach (string item in data.pc_list)
|
foreach (KeyValuePair<string, List<int>> unit in data.arm_list)
|
||||||
{
|
{
|
||||||
remote = CheckComputerName(item.ToString());
|
unitKey = unit.Key;
|
||||||
|
foreach (int position in unit.Value)
|
||||||
|
{
|
||||||
|
remote = CheckComputerName($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}");
|
||||||
if (remote == string.Empty)
|
if (remote == string.Empty)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{item}: имя ПК не распознано.");
|
AnsiConsole.WriteLine($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}: имя ПК не распознано.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Console.WriteLine($"{remote}: shutdown -r +{data.restart_time} \"{data.message}\"");
|
//AnsiConsole.WriteLine($"{remote}: shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||||
ExecuteCommandViaSSH(remote, $"sudo shutdown -r +{data.restart_time} \"{data.message}\"");
|
ExecuteCommandViaSSH(remote, $"sudo shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||||
Thread.Sleep(sleep_time);
|
Thread.Sleep(sleep_time);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Main()
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//Console.Title = typeof(Program).Assembly.GetName().Name;
|
|
||||||
Console.Title = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
Console.Title = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
||||||
|
if (args.Length > 0 && args[0] == "reboot")
|
||||||
|
{
|
||||||
|
StartRestartComputers();
|
||||||
|
return;
|
||||||
|
}
|
||||||
Menu();
|
Menu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,25 @@
|
|||||||
<Reference Include="Renci.SshNet, Version=2024.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
<Reference Include="Renci.SshNet, Version=2024.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\SSH.NET.2024.1.0\lib\net462\Renci.SshNet.dll</HintPath>
|
<HintPath>packages\SSH.NET.2024.1.0\lib\net462\Renci.SshNet.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Spectre.Console, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Spectre.Console.0.49.1\lib\netstandard2.0\Spectre.Console.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.DirectoryServices" />
|
<Reference Include="System.DirectoryServices" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.34.2" targetFramework="net48" developmentDependency="true" />
|
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.34.2" targetFramework="net48" developmentDependency="true" />
|
||||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net48" />
|
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net48" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||||
|
<package id="Spectre.Console" version="0.49.1" targetFramework="net48" />
|
||||||
<package id="SSH.NET" version="2024.1.0" targetFramework="net48" />
|
<package id="SSH.NET" version="2024.1.0" targetFramework="net48" />
|
||||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48" />
|
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||||
|
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
|
||||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
|
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"sleep_time" : 500,
|
"sleep_time": 100,
|
||||||
"restart_time": 1,
|
"restart_time": 1,
|
||||||
"message": "Плановая перезагрузка компьютера через 1 минуту!",
|
"message": "Плановая перезагрузка компьютера через 1 минуту!",
|
||||||
"pc_list" : [
|
"arm_list": {
|
||||||
"IT01",
|
"PIS": [ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 30, 31, 32 ],
|
||||||
"IT02",
|
"OBR": [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 34, 37, 40, 78, 79, 81, 82, 83, 84, 85, 86, 88, 89, 93, 94, 95, 97, 98, 99 ],
|
||||||
"630870MMP01",
|
"OBM": [ 9, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ],
|
||||||
"R54-630870MMP02"
|
"MMP": [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 68, 70, 71, 72, 73, 74, 75, 77, 78, 81, 82, 83, 84, 85, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97 ]
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user