Jump to content

Question on @IPAddress or @computername


pjw73nh
 Share

Recommended Posts

Greetings,

I am looking to write a script that will perform a command (netsh.exe) on only machines that our company owns. They would all have machine names that end with ".ehr.org". They would also fall into a few IP subnet ranges within our organization.

1.1.4x.x 10.x.x.x

I am trying to prevent the command from running on remote (personal) users machines that do not belong to our organization, but may connect over citrix or a PPTP VPN connection.

Which of the two macros ( @IPAddress or @computername ) would be best to use, and if possible could you give me a brief syntax for it. Or is there a better method for this task?

Thanks.

PAul.../NH

Link to comment
Share on other sites

Greetings,

I am looking to write a script that will perform a command (netsh.exe) on only machines that our company owns. They would all have machine names that end with ".ehr.org". They would also fall into a few IP subnet ranges within our organization.

1.1.4x.x 10.x.x.x

I am trying to prevent the command from running on remote (personal) users machines that do not belong to our organization, but may connect over citrix or a PPTP VPN connection.

Which of the two macros ( @IPAddress or @computername ) would be best to use, and if possible could you give me a brief syntax for it. Or is there a better method for this task?

Thanks.

PAul.../NH

Like this?

If StringRight(@Computername, 8) <> ".ehr.org" Or (StringLeft(@IPAddress1, 3) <> "10." And StringLeft(@IPAddress1, 5) <> "1.1.4") Then
    MsgBox(0, "Computer", "Not a company computer")
    Exit(1)
EndIf
MsgBox(0, "Computer", "This is a company computer")
Link to comment
Share on other sites

Like this?

If StringRight(@Computername, 8) <> ".ehr.org" Or (StringLeft(@IPAddress1, 3) <> "10." And StringLeft(@IPAddress1, 5) <> "1.1.4") Then
    MsgBox(0, "Computer", "Not a company computer")
    Exit(1)
EndIf
MsgBox(0, "Computer", "This is a company computer")

Hey, Thanks for the help. When I use the @computername line, it only returns the machine name of the computer. Not the FQDN. IE it returns IS2KPW instead of IS2KPW.EHR.ORG. Is there a way to get it to return the FQDN? If I get that, then I will be all set with the ** If StringRight(@Computername, 8) <> ".ehr.org" ** to compare it to Command.

Thanks again for the help. I really appreciate it.

Paul.../NH

Link to comment
Share on other sites

Do you use Active Directory? If so, you might want to check out ADFIND which, among other things, can get the full DN of computers in the AD.

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Or you could use this tool from the same developer:

ATSN

Summary

Command line Active Directory query tool. Converts IP addresses to subnet/site info. You can specify which DC you want to do the resolution of IP addresses to subnet/site names.

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
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...