windows - Powershell 获取 ipv4 地址到变量中

标签 windows powershell-3.0

在powershell 3.0 Windows 7中有没有简单的方法将本地计算机的ipv4地址放入变量中?

最佳答案

这是另一种解决方案:

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

关于windows - Powershell 获取 ipv4 地址到变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27277701/

相关文章:

powershell - PowerShell 中的成员类型(ScriptProperty、Property 和 NoteProperty)

iis - 如何从 PowerShell 指定应用程序池身份用户和密码

powershell - 通过 Set-AuthenticodeSignature 签署 powershell 脚本时出现未知错误

powershell - 如何使用Powershell列出其中一个文件夹中存在的文件夹结构中的重复文件

linux - tomcat在windows和linux下的区别

windows - 如何创建具有特定编码的 ZIP 文件

c - 一个 C 程序演示 cmd.exe 和一个 linux shell 例如bash,定界参数?

powershell - 使用嵌套脚本 block 确定问题的范围,然后尝试…最终

c++ - 错误 C2679: "binary ' <<': no operator found which takes a right-hand operand of type ' std::string'(或没有可接受的转换)”

c++ - 没有网表条目上下文时如何删除IP地址