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, ∼2689🔥, 0💬
Popular Posts:
What is "Application Information" in my Windows XP service list? And how is "Application Information...
Can I remove startup application "SynTPEnh.exe - Synaptics TouchPad Enhancements" to speedup my comp...
How do I display the total amount of time required to play all of the songs in my library? To view "...
How to connect your computer to a DSL line? Here are the steps of how to connect your computer to th...
Why HelpSvc.exe Is Causing Windows XP to Stop Responding - Using High CPU and Memory? Many users hav...