Collections:
Other Resources:
If-Else Conditions in Windows PowerShell Scripts
How to use if-else conditions in Windows PowerShell scripts?
✍: FYIcenter.com
PowerShell script supports the following if-else code block
to help you to perform tasks depending on logical conditions:
If (conditin1) { task1 } Elseif (condition2) { task2 ... } Else { other-task }
Here is a sample script on how to use if-else conditions:
$h = (Get-Date).Hour If ($h -ge 6 -and $h -lt 12) { "Good morning!" } Elseif ($h -ge 12 -and $h -lt 18) { "Good afternoon!" } Elseif ($h -ge 18 -and $h -lt 22) { "Good evening!" } Else { "Why are you not sleeping!?" }
⇒ Out-Host - Standard Output in Windows PowerShell Scripts
⇐ Logical Operations in Windows PowerShell Scripts
2016-10-30, ∼2379🔥, 0💬
Popular Posts:
A collection of 39 tutorials on understanding and managing Windows startup programs - Part II Contin...
What is the installed program "Windows SDK AddOn" on my Windows 7 computer? "Windows SDK AddOn" is a...
What is "SynTPEnh Caller Service" in my Windows 7 service list? And how is "SynTPEnh Caller Service"...
What is the startup program "fsquirt - fsquirt.exe" on my Windows 8 computer? Can I remove it to spe...
What is "User Profile Service" in my Windows XP service list? And how is "User Profile Service" serv...