Posts

Showing posts from March, 2020

How to loop "ipconfig /renew" until it gets IP address on remote PC to test DHCP using PowerShell

The script below will loop until it received IP address from DHCP server.  If id does not receive IP it will loop indefinitely or until you stop manually or reboot PC.  I used this script on remote PC, while it had and IP address but I needed to test if DHCP server is working or could reach client via site-to-site VPN.  If PC did not come up I knew I had to fix VPN or server, etc.  1. Open command prompt by right-clicking on the "command prompt" or PowerShell icon and select "Run as administrator" 2. If you open command prompt, type PowerShell to start power shell    Microsoft Windows [Version 10.0.18362.535]   (c) 2019 Microsoft Corporation. All rights reserved.   C:\WINDOWS\system32> powershell   Windows PowerShell   Copyright (C) Microsoft Corporation. All rights reserved. 3. Run these two command and save the computer name and domain name for later, we might need it.     PS C:\WINDOWS\system32> $env:computername     MYPC-TEST