Showing category results for PowerTip

Jun 22, 2016
Post comments count0
Post likes count0

PowerTip: Set a default value in a switch statement

Doctor Scripto

Summary: Use the default field in switch statement to have an assumed value. I was playing with Select-String and would like to have it default to a value if none was trapped for. How can I do that? Just use the Default keyword, and you can have an assumed value in the script block. In the following example, the switch is listening for the $DogS...

Windows PowerShellPowerTipguest blogger
Jun 21, 2016
Post comments count1
Post likes count0

PowerTip: Use PowerShell to identify a leap year

Doctor Scripto

Summary: Use PowerShell and Math to identify a leap year. Is there a way to use PowerShell to identify whether this year is a leap year? Actually there is! You can use a combination of Get-date to find out the year and the Modulus function in PowerShell. If the value is zero, the current year is a leap year!

Windows PowerShellPowerTipguest blogger
Jun 20, 2016
Post comments count0
Post likes count0

PowerTip: Extend a string array in PowerShell

Doctor Scripto

Summary: Use the built in features of PowerShell to easily add new Element to a string array. I created an array of strings in PowerShell, but I need to add to it. Is there a simple way to do this? Absolutely. Just use += to add an element to your string array. In the following example, we add a new element to the array that’s named $HSG

Windows PowerShellPowerTipguest blogger
Jun 10, 2016
Post comments count0
Post likes count0

PowerTip: Export Azure resource group as JSON by using PowerShell

Doctor Scripto

Summary: Use the Azure Resource Manager cmdlets to export a resource group as a JSON configuration. I’ve heard that JSON is used to define features in Azure Resource Manager. Is there a way to export a resource group in JSON format? Just use the Export-AzureRMResourceGroup cmdlet and provide the resource group name. It will automatically save a ...

Windows PowerShellPowerTipguest blogger
Jun 9, 2016
Post comments count0
Post likes count0

PowerTip: Search Azure Resource Manager image publishers by using PowerShell

Doctor Scripto

Summary: Use the Azure Resource Manager cmdlets to search publishers for a match. Could you show me an example of how to search through the list of publishers for Azure images? Just use the Get-AzureRMVMImagePublisher cmdlet, and filter on the PublisherName property. The following example searches for all publishers that contain the name, Window...

Windows PowerShellPowerTipguest blogger