HostName, IPアドレス by powershell
ホスト名、IPアドレス取得
ホスト名
- [Net.Dns]::GetHostName()
- $Env:COMPUTERNAME
- hostname
- (Get-CimInstance -Class Win32_ComputerSystem).Name
IPアドレス
- Get-NetIPAddress
- [Net.Dns]::GetHostAddresses(‘’).IPAddressToString
- [Net.Dns]::GetHostAddresses(‘’).IPAddressToString[1]
- ipconfig | where{$_ -match “IPv4 Address… … … . . : (?.*)”} | %{$Matches.ip}
その他
Get-NetIPAddress | where{$_.InterfaceAlias -eq "Ethernet"} | select -ExpandProperty IPAddress
(Get-NetIPAddress | where InterfaceAlias -eq "Ethernet" | select -ExpandProperty IPAddress)
(Get-NetIPAddress | where{$_.InterfaceAlias -eq "Ethernet"}).IPAddress