Software & Coding Articles

Page 26 of 83

How to retrieve the OS of the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 02-Sep-2021 2K+ Views

To retrieve the Azure VM OS using Azure CLI, we can use the “az vm” command but before that, need to make sure that you are connected to the Azure cloud and the subscription.PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.offer]" -otsvORPS C:\> az vm show -n VMName -g VMRG --query storageProfile.imageReference.offer - otsvOutputWindowsServerTo get the OS SKU or the operating system version, you can use, PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.sku]" -otsvOutput2016-DatacenterYou can also use the below command to get the OS of the VM without providing the resource group name.PS C:\> ...

Read More

How to get the load balancers connected to the Azure VM using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 626 Views

To get the load balancers attached to the Azure VM using PowerShell, we first need to retrieve the Azure VM network settings. For example, we have an Azure VM name “TestVM” and we willPS C:\> $vm = Get-AzVM -Name TestVM $nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]Once we have the network interface name, we need to retrieve the load balancer settings, and to get the Load Balancer settings we need to use the Get-AzNetworkInterface command.PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nicThe below command will retrieve the load balancer name.(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-3]To get the Load Balancer backend pool name, use the below command.(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-1]Overall Script −$vm = Get-AzVM ...

Read More

How to get the Azure VM virtual Network and the Subnet name using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 2K+ Views

To retrieve the Azure VM virtual network and subnet name, we first need to retrieve the AzureVM NIC information. To get the Azure VM NIC information, we need to use the Get-AzVM command, and then we can use the NetworkProfile property to retrieve the NIC name as shown below.PS C:\> $vm = Get-AzVM -Name TestVM $vmnic = ($vm.NetworkProfile.NetworkInterfaces.id).Split('/')[-1]Once we have the NIC name stored from the above command in the $vmnic variable, we can retrieve the NIC information using the Get-AzNetworkInterface command as shown below.$vmnicinfo = Get-AzNetworkInterface -Name $vmnicTo get the Virtual Network name attached to the VM use the ...

Read More

How to Install the Azure CLI on Windows using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 7K+ Views

To install the Azure CLI, you can download it from the location below,https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli/To install the Azure CLI using PowerShell, use the below command.Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows - OutFile .\AzureCLI.msi Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet' rm .\AzureCLI.msiTo check if the Az CLI is installed successfully run the Az in the cmd or the PowerShell.

Read More

How to get the Azure VM available sizes using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 894 Views

To get the Azure VM sizes using PowerShell, we can use the Get-AzVmSize command.To get all the supported Azure VM sizes as per location, use the below command.PS C:\> Get-AzVMSize -Location EastusOutputTo get available and supported size for the existing virtual machine, use the below command.Get-AzVMSize -ResourceGroupName ResourceGroup1 -VMName TestVM

Read More

How out-gridview selection works in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 2K+ Views

With the PowerShell Out-Gridview output, you have an option to select one or multiple selections.For example, if we run the below command, it will show us the output in the grid format.PS C:\> Get-Process | Out-GridViewIn this output, you don’t get any option to select the rows because its output mode is none. To add the single selection from the output, use the Output mode to single, and for the multiple selections use the output mode to multiple. Once you add the OutpuMode property you can see the OK and Cancel button at the bottom right of the grid.Single output ...

Read More

How to get the installed Azure VM extension using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 1K+ Views

To get the installed Azure VM extension using PowerShell, we can use the Get-AzVmExtension command and we need to provide VM name and the resource group name in the command.$vm = Get-AzVM -Name TestVM Get-AzVMExtension -VMName $vm.Name -ResourceGroupName $vm.ResourceGroupNameThe above command will retrieve all the extensions in detail of the VM named TestVM. To retrieve the extension name,Get-AzVMExtension -VMName $vm.Name -ResourceGroupName $vm.ResourceGroupName | Select NameOutput

Read More

How to create the Azure Storage context using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 4K+ Views

Storage context is helpful when you are working with the Storage accounts in the PowerShell session. It is like authenticating for Azure storage. Generally, we use the Azure storage account key and the connection string to create the Azure storage context.To create a new storage context, we need to use the New-AzStorageContext command but to use this command we need a storage account key or the connection string.We will use here Storage account key. We have the resource group “Az204” and the Storage account name “az204storage05june” which are stored in a variable.$rg = "az204" $storageaccount = "az204storage05june"To get the storage account ...

Read More

How to use Azure Rest API in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 5K+ Views

To use the Azure Rest API using PowerShell, we first need to connect to the Azure cloud account using the Connect-AzAccount. Once you are connected to the Azure Account, you can use the below authorization header (same has been provided on the MS website) which contains a bearer token to authenticate the rest API.$azContext = Get-AzContext $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRm ProfileProvider]::Instance.Profile $profileClient = New-Object - TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient - ArgumentList ($azProfile) $token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId) $authHeader = @{    'Content-Type'='application/json'    'Authorization'='Bearer ' + $token.AccessToken }Once you have the Authorization header available, you can use it for authentication. Now let assume we need ...

Read More

How to resolve - Relative path is not supported in PowerShell DSC?

Chirag Nagrekar
Chirag Nagrekar
Updated on 01-Sep-2021 677 Views

“Relative path is not supported” error generally occurs with the PowerShell DSC when we download a file from online or Website and we use “File” DscResource for that.In the below example, we are downloading the PowerShell 7.1.4 version from GitHub using DSC to the local computer and we get the error below.ExampleConfiguration FileCopy{    Node LocalHost{       File CopyFromBlob{          SourcePath = "https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.msi"          DestinationPath = "C:\Temp"          Ensure = 'Present'       }    } } FileCopy -OutputPath C:\Temp\dsc\FileCopy Start-DscConfiguration -Path C:\Temp\dsc\FileCopy -Wait -ForceOutputRelative path is ...

Read More
Showing 251–260 of 825 articles
« Prev 1 24 25 26 27 28 83 Next »
Advertisements