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, 1834🔥, 0💬
Popular Posts:
How to remove REFIEBAR.DLL - Microsoft Research Extra Toolbar Button and Extra Tools Menu Item for I...
Can I disable Windows service "Smart Card Helper" to speedup my computer? Windows service "Smart Car...
How to install Windows 7 Service Pack 1 (SP1)? I have the SP1 file downloaded. If you have the Windo...
Please can someone tell me which serial I need to use for WIndows 8 RC? Installation worked but now ...
What is "Human Interface Device Access" in my Windows XP service list? And how is "Human Interface D...