Friday, November 12, 2021

examples of powershell & azure

 >  connection 

Connect-AzAccount

>  Get info 

Get-AzVirtualNetwork

> assign to a variable 

$vnet_list = Get-AzVirtualNetwork

> test

$vnet_list

>  create an empty variable

$prefix_list=new-object collections.arraylist

>  test

$prefix_list

$prefix_list.count

$vnet_list[0]

$vnet_list[0].AddressSpace


>  filter specific ipaddress

$prefix_list_10=$prefix_list | where-object{$_ -like "10.*/2*"}


>  test 

$prefix_list_100

$prefix_list_100.count


> write to file 

$prefix_list_10 | out-file cloud_prefixes.txt -encoding ascii











No comments:

Post a Comment