Found 2043 Articles for Microsoft Technologies

Azure DSC node configuration using PowerShell

Chirag Nagrekar
Updated on 18-Feb-2022 06:17:44

458 Views

What is Azure State DSC?Azure State DSC is nothing but the DSC (Desired State Configuration) for the Azure VMs and can be configured from the Azure Automation Account. For the DSC there are two methods Push and Pull configuration but Azure is by default using the Pull server which constantly polls the target nodes and sends the configuration to the nodes.Azure DSC is itself a vast topic, in this article we will try the below configuration using PowerShell.Compose / Upload Node Configuration file.Compile node configuration.Attach compiled node configuration to the nodes.PrerequisiteAzure SubscriptionAzure Automation AccountConfiguration file (That we will create in ... Read More

PowerShell Desired State Configuration

Chirag Nagrekar
Updated on 18-Feb-2022 06:25:49

1K+ Views

OverviewPowerShell DSC is different than PowerShell scripting which ensures the remote windows systems are in the desired state and it is the declarative method unlike PowerShell Scripting and other programming languages which are considered imperative methods.In this article, we will go through the Push Method of the DSC which is a commonly used method for beginners and doesn’t require the Pull server. Pull server which polls the remote servers at some intervals and set the desired configuration for them and it is kind of automated.For the Push configuration, we will consider the below aspects.Get the DSC resource to Configure.Create the ... Read More

Importing / Exporting CSV file in PowerShell

Chirag Nagrekar
Updated on 18-Feb-2022 06:44:37

8K+ Views

In this article, we will work with CSV files in PowerShell which is considered one of the most efficient ways to deal with data.We have considered the below points for this article.Exporting data to the CSV file using PowerShell.Importing data from the CSV file using PowerShell.Let’s get started.Exporting data to the CSV file using PowerShellUsing Direct command outputTo export data to the csv file in PowerShell we can use Out-File which is the common cmdlet for storing the output to the file. The below command will get the top 10 CPU-consuming processes in the csv file.ExampleGet-Process | Sort-Object CPU -Descending ... Read More

Exception handling in PowerShell

Chirag Nagrekar
Updated on 18-Feb-2022 06:50:00

10K+ Views

In this article, we will go through the below points.What is an Exception in PowerShell?Terminating and Non-Terminating errors.Using Try / Catch block.Converting Non-Terminating error to Terminating Errors.Handling actual exception messages.What is the exception in PowerShell?Exception in PowerShell or other programming languages is the error or unexpected result that can be handled. For example, File not found while executing, dividing a number by zero.The exception can stop script execution if not handled properly.Terminating Errors and Non-Terminating ErrorsNon-Terminating errors don't halt script execution and it continuously runs script even if it is detected in the script. Below is an example of the ... Read More

Out-GridView in PowerShell

Chirag Nagrekar
Updated on 18-Feb-2022 06:57:40

4K+ Views

DescriptionOut-GridView in a PowerShell is the output format in the GUI format. Generally, we get the output on the console using the Format-Table or Format-List command. Similarly, Out-GridView is also the output format but we can interact with it because of the GUI format.Moreover, it provides us options to select single or multiple rows and we can store the selected output and can utilize them in the script.Out-Gridview with PipelineYou can pipeline output to the Gridview in a similar way as Format-Table or Format-List commands.Example1 − With Pipeline outputGet-Service | where{$_.StartType -eq 'Disabled'} | Out-GridViewOutputThe above command will get all ... Read More

How to get the available Azure VM sizes for the availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 12:04:54

150 Views

To get the Azure VM sizes available for the availability set, we can use the Get-AzVMSize command with the availability set name. Before running this command make sure that you are connected to the Azure Cloud (if not use Connect-AzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)Get-AzVMSize `    -ResourceGroupName MYRESOURCEGROUPAVAILABILITY `    -AvailabilitySetName myAvailabilitySetHere the Resource Group name is MyResourceGroupAvailability and the Availability set name is MyAvailabiltyset.Output

How to get the tags of the availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 12:06:32

114 Views

There are two ways to retrieve the availability set tags. Using the Tags property inside the availability tag and the second by using the Get-AzTag command.Before running this command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription).First, we will get the availability set properties and retrieve the tag property as shown below.$availablityset = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet $availablityset.TagsOutputTo get the tags using resource ID, we need to retrieve the resource ID using the Get-AvailabilitySet command.$availablityset = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet Get-AzTag ... Read More

How to find the disk type of the Azure Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:58:58

171 Views

There are two types of disks available in the Availability Set.Aligned − for the managed disks.Classic − for the unmanaged disks.To get the disk types of the availability set, we first need to retrieve availability set information and then we need to retrieve the SKU property which stores the disk typesBefore running this command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)To get the availability set information, $availablityset = Get-AzAvailabilitySet -ResourceGroupName MYRESOURCEGROUPAVAILABILITY -Name myAvailabilitySet if($availablityset.Sku -eq "Aligned"){"Managed disk"} else{"Unmanaged disk"}OutputRead More

How to get the update domain count of the Azure Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:54:09

146 Views

Virtual machines inside the Availability set get the update automatically, they reboot together and they are used for the patching of the virtual machines.To get the update domain count from the availability set, we can use the below command.Before running this command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)To get the availability set,$availablityset = Get-AzAvailabilitySet -ResourceGroupName Resourcegroupname -Name AvailabilitySetNameTo get the update domain count,$availablityset.PlatformUpdateDomainCountOutput

How to get the fault domain count of the Azure Availability set using PowerShell?

Chirag Nagrekar
Updated on 02-Sep-2021 11:44:49

158 Views

The fault domain in the Azure Availability set describes the VMs in the availability set that share the common Power, Storage, network switch, etc. If there is a failure in the fault domain then all the resources in the fault domain will become unavailable.Before running the command make sure that you are connected to the Azure Cloud (if not use ConnectAzAccount) and proper azure subscription (Set-AzContext to set the Azure subscription)$availablityset = Get-AzAvailabilitySet -ResourceGroupName ResourceGroupName -Name AvailabilitySetNameTo get the Fault domain countm$availablityset.PlatformFaultDomainCountOutput

Advertisements