Powershell get ipv4 address into a variable

后端 未结 12 2629
长情又很酷
长情又很酷 2021-01-31 08:23

Is there an easy way in powershell 3.0 Windows 7 to get the local computer\'s ipv4 address into a variable?

12条回答
  •  悲哀的现实
    2021-01-31 09:26

    This one liner gives you the IP address:

    (Test-Connection -ComputerName $env:computername -count 1).ipv4address.IPAddressToString
    

    Include it in a Variable?

    $IPV4=(Test-Connection -ComputerName $env:computername -count 1).ipv4address.IPAddressToString
    

提交回复
热议问题