Convert a String to Upper/Lowercase
1. Problem
You want to convert a string to uppercase or lowercase.
2. Solution
Use the ToUpper() and ToLower() methods of the string to convert it to uppercase and lowercase, respectively.
To convert a string to uppercase, use the ToUpper() method:
       PS >”Hello World”.ToUpper()
       HELLO WORLD
To convert a string to lowercase, use the ToLower() method:
       PS >”Hello World”.ToLower()
       [...]
Make Decisions with Comparison and Logical Operators
1. Problem
You want to compare some data with other data and make a decision based on that comparison.
2. Solution
Use PowerShell’s logical operators to compare pieces of data and make decisions based on them.
Comparison operators:
-eq, -ne, -ge, -gt, -lt, -le, -like, -notlike, -match, -notmatch, -contains, -notcontains, -is, -isnot
Logical operators:
-and, -or, -xor, -not
For a detailed [...]
Measure the Duration of a Command
1. Problem
You want to know how long a command takes to execute.
2. Solution
To measure the duration of a command, use the Measure-Command cmdlet:
       PS >Measure-Command { Start-Sleep -Milliseconds 337 }
       Days             : 0
       Hours            : 0
       Minutes          : 0
       Seconds          : 0
       Milliseconds     : 339
       Ticks            : 3392297
       TotalDays        : 3.92626967592593E-06
       TotalHours       : 9.42304722222222E-05
       TotalMinutes     [...]
Get the System Date and Time
1. Problem
You want to get the system date.
2. Solution
To get the system date, run the command Get-Date.
3. Discussion
The Get-Date command generates rich object-based output, so you can use its result for many date-related tasks. For example, to determine the current day of the week:
       PS >$date = Get-Date
       PS >$date.DayOfWeek
       Sunday
For more information about the [...]
Run a PowerShell Command
1. Problem
You want to run a PowerShell command.
2. Solution
To run a PowerShell command, type its name at the command prompt. For example:
       PS >Get-Process
       Handles NPM(K)   PM(K)   WS(K)  VM(M) CPU(s)   Id ProcessName
       ——- ——   —–   —–  —– ——   — ———–
           133      5   11760    7668     46         1112 audiodg
          184      5   33248     508     93         1692 avgamsvr
       [...]
Run Programs, Scripts, and Existing Tools
1.2.1. Problem
You rely on a lot of effort invested in your current tools. You have traditional executables, Perl scripts, VBScript, and of course, a legacy build system that has organically grown into a tangled mess of batch files. You want to use PowerShell, but don’t want to give up everything you already have.
1.2.2. Solution
To run [...]

