Found 463 Articles for PowerShell

How to get the IIS Application Pool queue length using PowerShell?

Chirag Nagrekar
Updated on 28-Apr-2021 13:37:43

758 Views

From the GUI, to retrieve the Application Pool queue length you need to check the Advanced Settings of the Application Pool.To get the IIS application Pool queue length using PowerShell, first, we need to the application pool name. There are two ways (and maybe others) to retrieve once we have the name of the application pool.For example, we need to retrieve the queue length for the application pool DefaultAppPool.(Get-IISAppPool -Name DefaultAppPool).queuelengthTo run the above command, you need the IISAdministration Module. You can also use the IIS PS drive but for that WebAdministration module should be loaded.(Get-ItemProperty IIS:\AppPools\DefaultAppPool).queuelengthRead More

How to get the IIS Application Pool names using PowerShell?

Chirag Nagrekar
Updated on 28-Apr-2021 13:39:35

5K+ Views

To get the IIS application pool names using PowerShell, you need to use the IIS PSDrive but for that, we need the IIS PowerShell module WebAdministration or IISAdministration on the server we are running the command.If the WebAdministration module is already installed, use the below command to import the module.Import-Module WebAdministration -VerboseOnce you Import the above module, you can see the IIS PSDrive will be activated in the current session.To get all the application Pools run the below command, Get-ChildItem IIS:\AppPools\OutputName                     State        Applications ----       ... Read More

How to retrieve the Operating system of the Azure VM using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:19:28

6K+ Views

To retrieve the OS details of the Azure VM, we need to use the Get-AzVM command.ExampleGet-AzVM -VMName TestMachine2k16When you run the above command, it retrieves the VM TestMachine2k16 information and there is an OSType property which shows that if the VM’s OS is Linux or Windows, or any other type.But when you select the OSType, you won’t get anything. See below.ExamplePS C:\> Get-AzVM -VMName TestMachine2k16 | Select OStype OStype ------Because this property is a part of another property and hence can’t be accessed directly. When you expose the full properties of the VM, you will get the StorageProfile, which ... Read More

How to delete the Azure Resource Group using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:16:22

2K+ Views

To delete the azure resource group using PowerShell, we need to use the Remove-AZResourceGroup command. But before using this command, make sure that no usable resources exist in the resource group that you want to delete.To check if the resources are available in the resource group, use the below command. Here we are using the TestRG resource group name.ExampleGet-AzResource -ResourceGroupName TestRGOnce you are confirmed that you need to delete the Resource Group then use the below command to delete the resource group.ExampleRemove-AzResourceGroup TestRG -Force -VerboseWhen you use the -Force parameter, you won’t be prompted for deletion confirmation.Read More

How to Export the Azure VMs using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:16:03

1K+ Views

To export the azure VMs using PowerShell, we first need to get their desired properties. The cmdlet Get-AZVM will get all the VMs connected to the particular subscription. To export them to the CSV file we can use the below command.ExampleGet-AzVM | Export-Csv .\AZVMs.csv -NoTypeInformationOnce you run the above command, you will notice that you get all the properties of the VM, and sometimes they are not needed. To get the particular properties of the VM use the Select-Object (alias Select) command.ExampleGet-AzVM | Select Name, ResourceGroupName, Location, @{N='VMSize';E={$_.HardwareProfile.VmSize}} | Export-Csv .\AzureVms.csv -NoTypeInformationIf you want to export the VMs from a ... Read More

How to create a new Azure resource group using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:15:46

1K+ Views

Azure Resource Group is a container that stores the resources like Virtual Machines, Storage, IP addresses, etc. To create a new Azure Resource group, we need to use the New-AZResourceGroup command.To use this cmdlet, you first need to connect to the Azure account, and then if you want to create a resource group for the particular subscription you need to select that subscription.To create a new resource group, you need the location for the resource group. The below code will first connect to your Azure account, selects the Azure subscription, and then creates a new resource group.Example$ErrorActionPreference = "Stop" Connect-AzAccount Set-AzContext -SubscriptionName 'Enter your subscription name here' New-AzResourceGroup -Name 'TestRG' -Location 'Central US' -Tag @{'RG'='APP'}OutputResourceGroupName : TestRG ... Read More

How to get the azure resources from the resource group using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:11:36

2K+ Views

To get the available resources from the resource groups using PowerShell, we need to use the Get-AZResource command. Suppose we have the resource group name AnsibleTestRG and we need to retrieve the resources from the resource group, then we will use the below command.ExampleGet-AzResource -ResourceGroupName AnsibleTestRGTo filter the output, OutputGet-AzResource -ResourceGroupName AnsibleTestRG | Select Name, ResourceType, LocationOutputIf there are multiple resource groups in the particular subscription, we can use the below commands to export the resources from the resource group to the CSV file.Example$ErrorActionPreference = "Stop" try {     Connect-AZAccount     Set-AzContext -SubscriptionName 'Your Subscription Name'     $rgs = Get-AzResourceGroup ... Read More

How to check if the Azure resource group is empty or not using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:10:50

977 Views

To check if the resource group is empty or not we need to check if the resource group contains any resources.For this example, We have a resource group name called  the TestRG and we need to check if it is empty.Example$resources = Get-AzResource -ResourceGroupName TestRG if($resources){"Resource group is not empty"} else{"Resource group is empty"}OutputResource group is emptyTo check if the resource groups in the particular subscription are empty or not, use the below code.OutputConnect-AZAccount Set-AzContext -SubscriptionName 'Your Subscription Name' $rgs = Get-AzResourceGroup Write-Output "Empty Resource Groups" foreach($rg in $rgs.ResourceGroupName){     $resources = Get-AzResource -ResourceGroupName $rg     if(!($resources)){ $rg } }Read More

How to create a temporary file using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:10:28

3K+ Views

To create a temporary file with the PowerShell, we can use the New-TemporaryFile command. This command creates a temporary file tmp.tmp where NNNN represents the random hexadecimal number.ExamplePS C:\> New-TemporaryFile Directory: C:\Users\Administrator.AUTOMATIONLAB\AppData\Local\Temp Mode                LastWriteTime         Length Name ----                -------------         ------ ---- -a----        4/10/2021   9:14 PM              0 tmpF624.tmpThe output path is selected based on the path defined at Path.GetTempPath() https://docs.microsoft.com/

How to get the disk performance using PowerShell?

Chirag Nagrekar
Updated on 12-Apr-2021 11:08:15

4K+ Views

To get the disk performance using PowerShell, we need to use the Performance counter of the disk. There are performance counters available for the Physical disk or the logical disk. To check what the disks related counter sets are available we can use the below command, ExamplePS C:\> Get-Counter -ListSet "*disk*" | Select CounterSetNameOutputCounterSetName -------------- FileSystem Disk Activity Storage Spaces Virtual Disk LogicalDisk PhysicalDiskWe will use a Logical disk to get more information about it. We will retrieve its counter first.ExampleGet-Counter -ListSet LogicalDisk | Select -ExpandProperty CounterOutputWe need to retrieve the Disk read time counter, ExampleGet-Counter -Counter '\LogicalDisk(*)\% Disk Read ... Read More

Advertisements