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, ∼2783🔥, 0💬
Popular Posts:
How to download Mozilla FireFox 2? If you want to try Mozilla FireFox 2, you can follow this tutoria...
What is the "Credential Manager (VaultSvc)" system service on Windows Server 2012? Can I disable "Cr...
Where to find tutorials on using Windows 7 Installed Programs and software? Here is a collection of ...
Have a windows 8 computer and need to download the Visual C++ Redistributable for visual studio 2012...
This is what I do Charms bar >Settings> Change my PC settings > User > "Trust this PC" When I get my...