pintas Posted April 12, 2018 Share Posted April 12, 2018 Hello everyone, I'm trying to display a list of network computers in an array, but net view command is slow to update its cache (more than 15 minutes!). Windows Explorer's network folder, on the other hand, is updated instantly. So i was thinking if it is possible to display the computers in Windows Network Folder. I've search the forum for other alternatives, but couldn't find any. Do you guys have any idea how to do this? Link to comment Share on other sites More sharing options...
Subz Posted April 12, 2018 Share Posted April 12, 2018 Are you on a domain? Link to comment Share on other sites More sharing options...
Earthshine Posted April 12, 2018 Share Posted April 12, 2018 If you post your code using the code tags <> I am sure someone here will help. I would be interested to know why the net command takes so long in the first place so please post your code so we can see what’s going on and we might be able to test My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
pintas Posted April 12, 2018 Author Share Posted April 12, 2018 (edited) 1 hour ago, Subz said: Are you on a domain? Yes, i'm on a domain. 1 hour ago, Earthshine said: If you post your code using the code tags <> I am sure someone here will help. I would be interested to know why the net command takes so long in the first place so please post your code so we can see what’s going on and we might be able to test The net view command displays the result promptly, but if i turn a machine off, it will still be displayed in net view command for more than 15 minutes. The problem isn't in the code itself but in net view command cache. I'm trying to find an alternative. I know i can show directories of a folder to display in an array, but i don't have a clue how to do that with a network folder. Edited April 12, 2018 by pintas Link to comment Share on other sites More sharing options...
Subz Posted April 12, 2018 Share Posted April 12, 2018 (edited) The following will show all computers on the domain, including Name, OS and Service Pack Requires AD Udf made by Water - https://www.autoitscript.com/forum/files/file/355-ad-active-directory-udf/ #include <Array.au3> #include <AD.au3> _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Error", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Local $aObjects = _AD_GetObjectsInOU("", "(objectcategory=computer)", 2, "name,operatingSystem,operatingSystemServicePack") If @error > 0 Then MsgBox(64, "Active Directory Function - Error", "No OUs could be found") Else _ArrayDisplay($aObjects, "Active Directory Function - Computer Objects in domain") EndIf _AD_Close() Edited April 12, 2018 by Subz Forgot to add Array.au3 Link to comment Share on other sites More sharing options...
pintas Posted April 12, 2018 Author Share Posted April 12, 2018 8 minutes ago, Subz said: The following will show all computers on the domain, including Name, OS and Service Pack Requires AD Udf made by Water - https://www.autoitscript.com/forum/files/file/355-ad-active-directory-udf/ #include <Array.au3> #include <AD.au3> _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Error", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Local $aObjects = _AD_GetObjectsInOU("", "(objectcategory=computer)", 2, "name,operatingSystem,operatingSystemServicePack") If @error > 0 Then MsgBox(64, "Active Directory Function - Error", "No OUs could be found") Else _ArrayDisplay($aObjects, "Active Directory Function - Computer Objects in domain") EndIf _AD_Close() I get the error in the picture. Should that script be ran from AD server? Link to comment Share on other sites More sharing options...
pintas Posted April 12, 2018 Author Share Posted April 12, 2018 I upgraded AutoIt to the latest version and got it working. However i get every machine on Active Directory, including offline machines. I'm trying to monitor when computers are online/offline. Is there any filter i can use for online machines in AD? I searched for it, but found only active/inactive filter. Link to comment Share on other sites More sharing options...
benched42 Posted April 18, 2018 Share Posted April 18, 2018 How about adding code to loop through $aObjects and Ping the computers and if you do not get a reply then remove that row from the array? Who lied and told you life would EVER be fair? Link to comment Share on other sites More sharing options...
BrewManNH Posted April 18, 2018 Share Posted April 18, 2018 I don't think that Active Directory can tell you the online/offline status of a computer, you might be able to find the last time it was logged on, the last logoff time stamp seems to not work very well. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
pintas Posted April 19, 2018 Author Share Posted April 19, 2018 (edited) 16 hours ago, benched42 said: How about adding code to loop through $aObjects and Ping the computers and if you do not get a reply then remove that row from the array? Thanks for replying... I was a little lost but i'm currently trying some 'multiping' solutions i found here on the forum, and it's working so far. Since i need to ping and update a list of 300 computers, i need a fast ping solution... It is still taking a couple of minutes to complete, but it's better than nothing. I'll try posting the code when its not so messy... 16 hours ago, BrewManNH said: I don't think that Active Directory can tell you the online/offline status of a computer, you might be able to find the last time it was logged on, the last logoff time stamp seems to not work very well. Exactly. It doesn't show when a machine is online or not, can't understand why, really. I listed the machines using something simillar to Subz code above to find what machines are active and inactive in AD and then i ping the active ones. I'm using the code below to find what machines are active: (!userAccountControl:1.2.840.113556.1.4.803:=2) And just removed the '!' to find what computers are inactive in AD: (userAccountControl:1.2.840.113556.1.4.803:=2) The result is pretty. Online computers; Offline active computers and Inactive computers. Edited April 19, 2018 by pintas Link to comment Share on other sites More sharing options...
AdamUL Posted April 19, 2018 Share Posted April 19, 2018 Have a look at this example. It may help you. This show if a user is logged in or not, but it can be edited to just show if a computer is online or offline. This script also uses a multiple processes approach. Adam Link to comment Share on other sites More sharing options...
pintas Posted April 20, 2018 Author Share Posted April 20, 2018 17 hours ago, AdamUL said: Have a look at this example. It may help you. This show if a user is logged in or not, but it can be edited to just show if a computer is online or offline. This script also uses a multiple processes approach. That is really nice. I'll try to use that. Thanks Adam! Link to comment Share on other sites More sharing options...
AdamUL Posted April 20, 2018 Share Posted April 20, 2018 Your welcome pintas. I hope it helps. Adam Link to comment Share on other sites More sharing options...
pintas Posted April 20, 2018 Author Share Posted April 20, 2018 4 minutes ago, AdamUL said: Your welcome pintas. I hope it helps. Adam It will. I'm not sure if can get it working now, but i'm going to use it for sure. It's great! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now