Posts

Showing posts from June, 2020

Convert Dynamic IP to static IP in a Windows computer or server

Make sure the Powershell should be opened with  elevated privilege  $Domain =  read-host "Enter the domain name for the DNS Suffix " #Collect Network Configuration variables $IfName = (Get-NetIPInterface -AddressFamily IPv4 -Dhcp Enabled).InterfaceAlias $IfIndex = (Get-NetIPInterface -AddressFamily IPv4 -Dhcp Enabled).ifIndex $IP = (Get-NetIPConfiguration -InterfaceIndex $IfIndex | Select-Object -ExpandProperty IPv4Address).IPv4Address Start-Sleep -Seconds 20 Write-host "IP Address set as: $IP." $Gateway = (Get-NetIPConfiguration -InterfaceIndex $IfIndex | Select-Object -ExpandProperty IPv4DefaultGateway).NextHop Write-host "Gateway set as: $Gateway." $PrefixLength = Get-NetIPAddress -InterfaceIndex $IfIndex | Select-Object -ExpandProperty PrefixLength $DNSServers = @() $DNS = @() $DNS = Get-DnsClientServerAddress -InterfaceIndex $IfIndex | Select-Object -ExpandProperty ServerAddresses foreach($item in $DNS) {     $DNSServers += $item } Write-host  "S...

Login into Azure using Powershell

Import-Module -Name Az Login-AzAccount  # This will prompt for the username and password get-azsubscription $getallSubscriptions = Get-AzSubscription $getallSubscriptions  will have the complete list of subscriptions 

Export Azure VM details to CSV with Tags

Import-Module -Name Az Login-AzAccount get-azsubscription $getallSubscriptions = Get-AzSubscription foreach($subscription in $getallSubscriptions) { Select-AzSubscription $subscription $vms = Get-AzVM foreach($vm in $vms) { { $TagOut =$nulll foreach($tag in $vm.tags.keys) { $Tagz=$tag+ ":" + $vm.tags.$tag+ "," $TagOut=$TagOut+$Tagz }    $value = $($subscription.Id) + "," + $($rg.ResourceGroupName)  + "," + $vm.Name + ","  + "," +$vm.Id   + "," +  $TagOut  Add-content -path "C:\azure-Vm.txt" -value $value $TagOut will have the complete tags with comma separated you can rename the output file to csv and make use of it