Found 461 Articles for PowerShell

Difference between PowerShell and CMD

Pradeep Kumar
Updated on 09-Aug-2022 13:41:39
The history of "batch file scripting" can be traced all the way back to 1981, when the first version of MS-DOS was made available as an operating system for IBM personal computers. It was essentially a copy of the CP/M operating system that was developed by Digital Research. CP/M was one of the very first computer operating systems. Microsoft built it so that it could run on IBM PCs, operating as both the kernel and the shell, and it also included several functionalities that are seen in other shells. Over the years, Microsoft has released multiple versions of DOS, which ... Read More

Azure DSC node configuration using PowerShell

Chirag Nagrekar
Updated on 18-Feb-2022 06:17:44
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
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
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
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
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
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
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
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
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
1 2 3 4 5 6 7 ... 47 Next
Advertisements