Kaseya Community

Deployment of script based on SUBNET

  • i want to make a script that first checks the subnet the HOST is on BEFORE it continues with the script.

    IS there a way that i can do this?

    e.g. a host has an IP of 192.168.1.5 /24, the subnet would be 192.168.1.x with the 24 bit subnet mask,

    there are multiple subnets inthe network e.g. 192.168.2.x, 192.168.3.x ... perhaps indicating a WAN link inbetween each subnet

    if the USER logs on and gets a 192.168.1.x address they will download the pacakge from the 192.168.1.x package server location, therefore not using the WAN link

    all i need is a check for allowable subnet ranges, before the script starts, is this possible?

    Thanks in advance




    Legacy Forum Name: Deployment of script based on SUBNET,
    Legacy Posted By Username: bobobobo51
  • I haven't tested this, but it's worth a shot. First of all, create a login or startup script for a machine that runs the following VBS file like this:

    cscriptipaddress.vbs >>ipaddress.txt

    ipaddress.vbs:

    'Only go for the first card
    sNic = WsShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows
    NT\CurrentVersion\NetworkCards\1\ServiceName")
    If sTcpipRegKey <> "Microsoft" And Err.Number = 0 Then
    sTcpipRegKey = "HKLM\SYSTEM\CurrentControlSet\Services\" & sNic &
    "\Parameters\Tcpip\"
    bIsDHCP = WsShell.RegRead(sTcpipRegKey & "EnableDHCP")
    If bIsDHCP Then
    IPAddress = WsShell.RegRead(sTcpipRegKey & "DhcpIPAddress")
    Else
    IPAddress = WsShell.RegRead(sTcpipRegKey & "IPAddress")
    End If
    End If


    Now you will have their ip address in a text file. From there, use if/then statements in a batch file to do whatever you want - download something, run something, etc. Does that help?


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: elehman