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, ∼3035🔥, 0💬
Popular Posts:
What is "Net Driver HPZ12" in my Windows 7 service list? And how is "Net Driver HPZ12" service relat...
How to configure Apache server to run PHP engine as CGI on Windows systems? If you have followed our...
What is the "World Wide Web Publishing Service (W3SVC)" system service on Windows Server 2012? Can I...
A new tab called "Services" is added in "Task Manager" on Windows Vista and Windows 7. What is this ...
What is a DSL modem? A DSL modem is a device that is used to interface your computer and the DSL lin...