使用powershell 导出Azure VM信息
程序员文章站
2022-03-09 12:17:07
...
$path="D:\vm-wyzx.csv"
$vmlist=Get-AzureVM
[email protected]()
foreach($vm in $vmlist){
$vmObject = New-Object PSObject
$vmObject | Add-Member -MemberType NoteProperty -Name "VmName" -Value $vm.DNSName
$vmObject | Add-Member -MemberType NoteProperty -Name "VmSize" -Value $vm.VirtualNetworkName
$vmObject | Add-Member -MemberType NoteProperty -Name "IpAddress" -Value $vm.IpAddress
$vmObject | Add-Member -MemberType NoteProperty -Name "AvailabilitySetName" -Value $vm.AvailabilitySetName
$vmObject | Add-Member -MemberType NoteProperty -Name "IpAddress" -Value $vm.DNSName
$vmObject | Add-Member -MemberType NoteProperty -Name "AvailabilitySetName" -Value $vm.VirtualNetworkName
$result+=$vmObject
}
$result | Export-Csv $path -NoTypeInformation -Encoding UTF8