欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

使用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
相关标签: powershell azure