【Powershell】物理サーバ・Hyper-VのIP・MACアドレスを取得する

note
  • Export-Csvでそのままcsv出力が可能

物理サーバ

Get-WmiObject Win32_NetworkAdapterConfiguration |
Select-Object Description,@{ L = "IPv4Address"; E = { $_.IPAddress[0] } },@{ L = "IPv6Address"; E = { $_.IPAddress[1] } },MACAddress |
Where-Object { $_.IPv4Address -ne $null -or $_.IPv6Address -ne $null }

Hyper-V仮想マシン

Get-VM |
Get-VMNetworkAdapter |
Select-Object VMName,Name,@{ L = "IPv4Address"; E = { $_.IPAddress[0] } },@{ L = "IPv6Address"; E = { $_.IPAddress[1] } },MACAddress
タイトルとURLをコピーしました