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, 1713🔥, 0💬
Popular Posts:
What is service "wudfsvc" and library "wudfsvc.dll" on Windows Vista? "wudfsvc" is a system service ...
What is smss.exe process - Windows NT Session Manager? Process smss.exe is part of Windows system. I...
How to start and stop a Windows XP service? If you want to start or stop a Windows service, you can ...
What is "Superfetch" in my Windows XP service list? And how is "Superfetch" service related to SysMa...
How to remove NetZero Toolbar from Internet Explorer (IE) 7 browser? NetZero Toolbar offers you nice...