예제 #1
0
        public override void Run(Dictionary <String, Parameter> RunParams)
        {
            List <string> targets = Proccessing.GetTargets(RunParams);

            if (targets.Count > 0)
            {
                foreach (string target in targets)
                {
                    string computer = target;
                    try
                    {
                        if (computer == null)
                        {
                            computer = "localhost";
                        }
                        List <string>           printedUsers = new List <string>();
                        List <Net.LoggedOnUser> users        = Net.GetNetLoggedOnUsers(computer);
                        Printing.CmdOutputHeading($"Logged on users for {computer}");
                        foreach (Net.LoggedOnUser user in users)
                        {
                            if (!user.UserName.EndsWith("$") && !printedUsers.Contains(user.UserName))
                            {
                                Printing.CmdOutputItem($"User {user.UserName} is logged in from {user.ComputerName}");
                                printedUsers.Add(user.UserName);
                            }
                        }
                    }
                    catch
                    {
                        Printing.Error($"Could not get logged on users for {computer}");
                    }
                }
            }
        }