79721565

Date: 2025-07-31 16:15:36
Score: 1
Natty:
Report link

Try something like this to use the stream option instead of trying to interpret CIM etc...

$IPConfig = get-netIPConfiguration | Out-String -Stream
ForEach($item in $IPConfig) {
            If($item.ToString() -like '*DefaultGateway*') {
                    $defaultGateway = $item.Replace('IPv4DefaultGateway   : ', '')

            }
       }

write-host $defaultGateway
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Brian Holt