Powershell 获取 ipv4 地址到一个变量中 [英] Powershell get ipv4 address into a variable
本文介绍了Powershell 获取 ipv4 地址到一个变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
powershell 3.0 Windows 7 中是否有一种简单的方法可以将本地计算机的 ipv4 地址放入一个变量中?
Is there an easy way in powershell 3.0 Windows 7 to get the local computer's ipv4 address into a variable?
推荐答案
这是另一个解决方案:
$env:HostIP = (
Get-NetIPConfiguration |
Where-Object {
$_.IPv4DefaultGateway -ne $null -and
$_.NetAdapter.Status -ne "Disconnected"
}
).IPv4Address.IPAddress
这篇关于Powershell 获取 ipv4 地址到一个变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文