Jump to content

check if remote pc is powered on and you have admin permissions


Recommended Posts

Hello,

I am searching for a better (faster) way to check if a remote Windows PC is powered on and you have admin permissions then using fileexists on a admin share?

Because now I do it this way:

$IP = 192.168.1.100
If ping($IP) <> 0 then
    $online = True
    If  FileExists("\\" & $IP & "\admin$\explorer.exe") Then
        $admin = true
    Else
        $admin = false
    EndIf
Else
    $online = false
EndIf

Because the timeout on accessing SMB shares is very long this can take a while if you check 50+ PC's (also the application is writing "not responding" during this time)

Is there a faster/better way to check if the PC is powered on and you have admin permissions then Fileexists on the admin share?

Thanks for your help!

Link to comment
Share on other sites

Maybe with WMI ?

If IsObj( ObjGet("winmgmts:\\" & $IP & "\root\CIMV2")) Then
    MsgBox(0, "", "The remote computer is alive and the account is an admin")
Else
    MsgBox(48, "", "Unable to connect to the remote computer.")
EndIf
Link to comment
Share on other sites

@Spider001 if you look at my code than you see I use ping before fileexists and yes it helps to sort out PC's that are offline,

but it dont give me information about the OS if its completely booted or if i have admin rights

@jguinch WMI is also a good idea, but I ask WMI after fileaccess because in my opinion WMI is more complicate than SMB (random port and problems with Firewall)

Any ideas left?

Link to comment
Share on other sites

if the main issue is wasting time waiting for the remote pc's to respond in turn, and you have a relatively fixed inventory of pc's then, set-up a monitoring system. consult the monitoring system before performing your admin test.

(regardless, if you are managing a network, a monitoring system is kind of a must-have, to my opinion).

if your inventory of pc's is changing constantly, then search the forum for several solutions and methods for simultaneous pinging. here are some you may find interesting:

'?do=embed' frameborder='0' data-embedContent>>

'?do=embed' frameborder='0' data-embedContent>>

'?do=embed' frameborder='0' data-embedContent>>

and an external link:

http://windowsitpro.com/windows/worry-free-way-ping-remote-computers

basically, the simple way is:

the main script calls several Run() to ping, and redirects ping output to a file or another buffer which can be read later. each Run() creates a separate process, so they are not waiting for each other. when all are done, the main script can parse the output of each ping, and continue checking only the alive pc's.

there are more complex ways of doing it, but they are... well... complex.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...