Category: PowerShell

Ternary Operator in PowerShell

I’m very noob .Net C# developer, but I remember this: <compare> ? <value of true> : <value of false> (a == ‘a’ ) ? 1 : 2 I want the same thing in PowerShell, here we go:


Which I came up with a more readable and something easy to memory:


PowerShell – Multidimensional arrays in PowerShell

You may have some arrays like this:

Then you may want to combine them together:

But unfortunately it’s not simple like this… You will get:

Suppose to be 2, right? Why it’s 6… Let’s identify…

But what I want it to be is $School contains $year1 and $year2, and $year1 contains…

How to convert string to Base64 and vice versa using Powershell

Working with Consul without UI is the correct way to go, which also help you with the productivity!!! (True?, hahaha~~)   Anyway, I’m not allowed to have a UI for it, come down to have read the correct value and make sure it’s the one we want it to be in there, I need to…

Send email via PowerShell

I need to send a large number (more than 100) emails to my wife for her needs. She has a folder that contains tones pdf files, needs to be send to an email address one file per email. So I created this script to send the mail… For sure you need to modify this if…

PowerShell – Check Class Properties (UCS as example)

Here is the JSON for an Object:

The structure of this object: BootPolicy BootPolicyConfiguration Boot device order When I’m trying to add the first boot device order object, following command should be run:

This command will pass the PropertyMap as hastable: Access LunId Order But when I’m running the second boot device order…