pjw73nh Posted December 2, 2005 Share Posted December 2, 2005 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 More sharing options...
Dickb Posted December 2, 2005 Share Posted December 2, 2005 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 More sharing options...
pjw73nh Posted December 2, 2005 Author Share Posted December 2, 2005 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 More sharing options...
jefhal Posted December 2, 2005 Share Posted December 2, 2005 (edited) 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 December 2, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
jefhal Posted December 2, 2005 Share Posted December 2, 2005 Or you could use this tool from the same developer:ATSNSummaryCommand 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 More sharing options...
MSLx Fanboy Posted December 2, 2005 Share Posted December 2, 2005 I don't have an AD network to test this suggestion on, but you might try @LogonDomain or @LogonDNSDomain Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) 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