I'm not sure if this is a fault by me, or if my PowerShell isn't operating correctly.
get-netipconfiguration | where {$_.subnetmask}
I'm not really able to find any examples online that work either. I even tried using a WMI
command and it still won't work. I have the latest version of PowerShell and have done this before, but my previous method is not working. Currently I'm using this for IPaddress
fetching which works wonderfully
$ipaddress = (Get-NetIPConfiguration).IPv4Address.IPAddres
That works great, but I can't seem to figure out how I could use it to display the DNS
and Subnet mask
as well. I know this is probably a noob question, but they've changed a bit of stuff and I'm trying to find a cut and dry way of doing it without too much code. Any help is appreciated!
You could retrieve this information using WMI
:
Get-WmiObject Win32_NetworkAdapterConfiguration |
Where IPEnabled |
Select IPSubnet, DNSServerSearchOrder, IpAddress
With PWSH 7.x, WMI
won't be available. So that will of course be:
Get-CimInstance Win32_NetworkAdapterConfiguration |
Where IPEnabled |
Select IPSubnet, DNSServerSearchOrder, IpAddress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With