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, ∼3284🔥, 0💬
Popular Posts:
What is "IP Helper" in my Windows XP service list? And how is "IP Helper" service related to iphlpsv...
How to install the latest Lenovo ThinkPad Bluetooth driver on my Windows 7 system? I have downloaded...
I don't know if this is a Windows Problem or an HP problem. HP says windows. But anyhow I have a bra...
I just installed the Windows 8 Release Preview on the Samsung slate that we attendees got at the MIX...
What is the HP computer registration process? If you bought a new HP computer and doing the initial ...