Welcome Forums General PowerShell Q&A Checking IP conflict using Powershell

Viewing 2 reply threads
  • Author
    Posts
    • #166187
      Participant
      Topics: 1
      Replies: 2
      Points: 16
      Rank: Member

      Hi, I have to write a powershell script for checking if there is an address conflict.

      We have several laptops, but only two can be connected  at the same time, one with ip .24 and the other with .25, we cannot have dhcp server.

      My idea is to launch a powershell script at startup or logon, the script should check if there is another pc with the same address, if there is another computer with the same ip it should change its address to the other, so the .24 should become .25 and viceversa.

      How can I check ip conflict in powershell?

       

      Thanks, Pietro.

    • #166220
      Participant
      Topics: 1
      Replies: 63
      Points: 355
      Helping Hand
      Rank: Contributor

      Why not just hardcode the IP address?

      • #166247
        Participant
        Topics: 1
        Replies: 2
        Points: 16
        Rank: Member

        Is a bit long to explain, but I have to automatically manage the situation in which two laptops with the same ip could be present on the same network.

         

        Thanks, Pietro.

    • #166253
      Senior Moderator
      Topics: 8
      Replies: 1160
      Points: 4,056
      Helping Hand
      Rank: Community Hero

      Since the system requires an IP address at least to check if someone else has same IP, there is only one way I could see here,

      set the ip address and get it, if it is not returning APIPA range, then no conflict has occurred.

      • #166480
        Participant
        Topics: 1
        Replies: 2
        Points: 16
        Rank: Member

        Since the system requires an IP address at least to check if someone else has same IP, there is only one way I could see here,

        I can give .24 or .25 static ip to the pc, but I need to check using powershell if there is an ip conflict. Windows emits an alert when it finds a ip conflict, I supposed I could intercept this alert using powershell.

        set the ip address and get it, if it is not returning APIPA range, then no conflict has occurred.

        I’m trying something similar, I’m giving to the pc an ip in a range (not a dhcp, but simply I choose a random ip out of a pool of five or six), then I check if .24 or .25 are in use and then I choose the one that is free. It is not what I want, but I’ve to start somewhere.

         

        Thanks, Pietro.

Viewing 2 reply threads
  • The topic ‘Checking IP conflict using Powershell’ is closed to new replies.