Monday, 20 March 2017

DHCP Fail over service do not synchronize MAC address between two Servers

DHCP Fail over service do not synchronize MAC address between two Servers


Step 1:  Copy below Power shell script and paste in Notepad




$MasterServerHostname = "MyServerHostname";

# Get the LOCAL filters from localhost
$lfilters = Get-DhcpServerv4Filter

# Get the REMOTE filters from $MasterServerHostname
$rfilters = invoke-command -computername $MasterServerHostname { Get-DhcpServerv4Filter }

# Delete the local Filter Set
ForEach ($filter in $rfilters) {
  Remove-DhcpServerv4Filter -MacAddress $filter.MacAddress
}

# Import the new Filter Set
ForEach ($filter in $rfilters) {
  write-host $filter.List
  write-host $filter.MacAddress;
  write-host $filter.Description
Add-DhcpServerv4Filter -List $filter.List -MacAddress $filter.MacAddress -Description $filter.Description
}




Step 2:  Change The name of MyServerHostname = Primary DHCP server computer name.

Step 3:  Save the notepad in .ps1 extension.  (ex= mac.ps1)  and save this file in Secandary DHCP server.

Step 4:  Go to Secondary DHCP server and run this Powershell script file.


Note :  ( Only change "MyServerHostname"  to "Primary server host name( i e: Master server)" ) in Script


How to run in Power shell

Open power shell as Run as Administrator

Redirect to script file path.
and type   ./mac.ps1  (  While running you have to mention  ./  before entering file name)


Schedule in Task Scheduler


Go to Create task.
Mention Name
Check the option in Run with Highest privileges
In Trigger, click new and select daily and specify start time.
In Action, Click New, In Program / Script  enter  powershell -file "C:\mac.ps1"  (specify file location).
Then click OK twice.



No comments:

Post a Comment

PHP vs Python : Which one is the Best Server-Side Programming?

PHP vs Python, the two most popular back-end programming languages. Python has the variety of dynamic features with simple script whereas ...