February 18, 2018 at 4:54 am #93973
I am developing a Powershell app for my company to allow our Help Desk to get some details quickly to copy into a ticket. I have the following commands which appears to work and get the desired result
(Get-NetIPaddress -InterfaceAlias Ethernet*).IPv4Address
(Get-NetIPaddress -InterfaceAlias Wireless*).IPv4Address
My issue is if I disconnect the ethernet cable or from the wireless and then re-run the command, I still get the IP addresses I got when I ran the command while connected and cannot find a way to clear this or to read this live.
I would prefer to keep the Wireless and wired IP Address separate, but is anyone able to suggest a way in which I can keep this to the current IP address (or show nothing if disconnected) and only give me the IP address, no other text.
Thank you in advance of any help you may be able to provide
February 18, 2018 at 6:36 am #93978
This is not a PowerShell issue. It is a DHCP lease specification.
Using DHCP policies to set different lease durations for different device types
An enterprise has the following types of devices for which network connectivity is required: servers, desktops, printers, desk phones and mobile phones. The admin would like each type of device to have different lease duration-
• Desktops: Standard lease duration of 8 days (default set for a scope).
• Printers: Lengthier lease duration of 60 days as they are unlikely to be moved around frequently and are expected to be up and running all the time.
• Servers: Server computers which are typically expected to be stationery and up all the time can be configured for a lengthy lease duration of 60 days.
• Desk phones: Again these have similar requirements of lengthy lease duration of 30 days.
• Mobile phones: These devices are expected to move in and out of the network; hence smaller lease duration of just 8 hours is desired.
One a nic gets issues an IPA, it will maintain that for the length of time set by policy or until dhcp releases or you manually remove it.
The old faithful DOS approach
/release [Adapter] : Sends a DHCPRELEASE message to the DHCP server to release the current DHCP configuration and discard the IP address configuration for either all adapters (if an adapter is not specified) or for a specific adapter if the Adapter parameter is included. This parameter disables TCP/IP for adapters configured to obtain an IP address automatically. To specify an adapter name, type the adapter name that appears when you use ipconfig without parameters.
Release Renew IP Addresses Using PowerShell
You can use this with-in you own script or you can write a funtion on it. This script using WMI and using the class Win32_NetworkAdapterConfiguration. then using the RenewDHcpLease and ReleaseDHCPlease methods of the class.To know more about this
You must be logged in to reply to this topic.