get IPv4 address into a variable

powershell, powershell-3.0, windows

Solution

Here is another solution:

$env:HostIP = (
    Get-NetIPConfiguration |
    Where-Object {
        $_.IPv4DefaultGateway -ne $null -and
        $_.NetAdapter.Status -ne "Disconnected"
    }
).IPv4Address.IPAddress

Problem

Is there an easy way in PowerShell 3.0 on Windows 7 to get the local computer's IPv4 address into a variable?

Original source