dhcp_check.ps1 - michael-D-S/SYS-265 GitHub Wiki

  1. Get the current logged-in user $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
  1. Get network adapter configuration using WMI $networkAdapter = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }
  1. Retrieve the relevant details $ipv4Address = $networkAdapter.IPAddress[0] $dhcpServer = $networkAdapter.DHCPServer $gateway = $networkAdapter.DefaultIPGateway[0] $dnsServers = $networkAdapter.DNSServerSearchOrder -join ', '
  1. Output network information Write-Host "------ Network Information ------" Write-Host "User: $user" Write-Host "IPv4 Address: $ipv4Address" Write-Host "DHCP Server IP: $dhcpServer" Write-Host "Gateway IP: $gateway" Write-Host "DNS Servers: $dnsServers" Write-Host "---------------------------------"
⚠️ **GitHub.com Fallback** ⚠️