Running Conditional Powershell Script After IP Assignment from DHCP in AD ?!

Discussion in 'Windows Server' started by tryllz, Apr 20, 2023.

  1. tryllz

    tryllz MDL Novice

    Oct 4, 2010
    7
    0
    0
    #1 tryllz, Apr 20, 2023
    Last edited: Apr 20, 2023
    Hi,

    I wanted to know how to achieve this as I could not it find any where, and unsure if this is possible.

    I have a DC server with DNS, DHCP configured. What I want to do is once a client receives an IP from the DHCP server (IP address is issued only for MAC address reserved against it), then a script should run on the client (bear in mind the client has not joined AD domain, it just received an IP).

    Thank You
     
  2. Konde

    Konde MDL Junior Member

    Aug 1, 2009
    72
    22
    0
    If you know the administrator account of the non domain-joined and the administritive share is enabled beforehand, you could be pinging the desired IP and psexec the computer when it start replying.
    What exactly are you trying to accomplish? I think pxe boot could be an option for some tasks.
     
  3. tryllz

    tryllz MDL Novice

    Oct 4, 2010
    7
    0
    0
    Hi,

    Sorry for the latd reply.

    I'm trying to automate server deployments in a homelab. In my case I have a Primary DC with scripts to configure Secondary DC and some other servers.

    The idea is as follows.

    The primary DC is configured with DHCP Mac address IP reservation, soon as Secondary DC receives the IP reserved for it, a script is copied to the Secondary DC using New-PSSession and the script is executed in the Secondary DC.

    I'm unsire how PXEBoot can be used for this..

    Thanks..
     
  4. sebus

    sebus MDL Guru

    Jul 23, 2008
    6,356
    2,026
    210
    You probably could use some "semi clever" scheduled task on primary DC to run often to check for existence of "remote" IP (which you know exactly what it would be, as it is your reservation) or even better, to check if DHCP issued IP (some clever parsing of DHCP Server service debug logs) and then double confirm the existence of "remote" IP & then carry on doing whatever you want/need