Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static List<string> _targets = new List<string>();
- static List<string> _offline = new List<string>();
- public enum status
- {
- offline, logged, cleared
- }
- static void Main(string[] args)
- {
- Console.WriteLine("Finding all computers in Active Directory...");
- _targets = getComputers();
- string user = "xxxxxxxx";
- while (true)
- {
- doSearch(_targets, user);
- _targets = _offline;
- _offline.Clear();
- }
- }
- static void doSearch(List<string> targets, string userName)
- {
- Console.Clear();
- int count = 0;
- Console.WriteLine("Searching each computer for ******....");
- foreach (string target in targets)
- {
- if (PCisOnline(target))
- {
- if (hasLoggedOn(target, userName))
- {
- Console.WriteLine("***" + target + "***\n" + count + "\\" + _targets.Count);
- Log(target, status.logged);
- }
- else
- {
- Log(target, status.cleared);
- }
- }
- else
- {
- Console.WriteLine("*" + target + "\n" + count + "\\" + _targets.Count);
- _offline.Add(target);
- Log(target, status.offline);
- }
- count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement