Jump to content
pintas

Display computers in network folder

Recommended Posts

pintas

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?

Share this post


Link to post
Share on other sites
Subz

Are you on a domain?

Share this post


Link to post
Share on other sites
Earthshine

 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

 

Share this post


Link to post
Share on other sites
pintas
Posted (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 by pintas

Share this post


Link to post
Share on other sites
Subz
Posted (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 by Subz
Forgot to add Array.au3

Share this post


Link to post
Share on other sites
pintas
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?

Cap.PNG

Share this post


Link to post
Share on other sites
pintas

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. 

Share this post


Link to post
Share on other sites
benched42

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?

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
pintas
Posted (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.

image.png.d05d2b497c7d3c6fe292264a339793e7.png

Edited by pintas

Share this post


Link to post
Share on other sites
AdamUL

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

 

Share this post


Link to post
Share on other sites
pintas
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!

 

 

Share this post


Link to post
Share on other sites
AdamUL

Your welcome pintas.  I hope it helps.  

 

Adam

 

Share this post


Link to post
Share on other sites
pintas
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! :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×