{"id":3965,"date":"2024-05-13T16:40:37","date_gmt":"2024-05-13T16:40:37","guid":{"rendered":"https:\/\/wiki.thomasandsofia.com\/?p=3965"},"modified":"2024-05-13T16:40:37","modified_gmt":"2024-05-13T16:40:37","slug":"powershell-conditions","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=3965","title":{"rendered":"Powershell: Conditions"},"content":{"rendered":"<h1>Conditions<\/h1>\n<p><strong>Terrinaries<\/strong><\/p>\n<ul>\n<li>-eq Equal To<\/li>\n<li>-ne Not Equal To<\/li>\n<li>-le Less than or Equal To<\/li>\n<li>-lt Less than<\/li>\n<li>-ge Greater than or Equal To<\/li>\n<li>-gt Greater than<\/li>\n<\/ul>\n<p><strong>Boolians<\/strong><\/p>\n<ul>\n<li>-and And: ($x -eq $y -and $i -ne $j)<\/li>\n<li>-or Or: ($x -eq $y -or $i -ne $j)<\/li>\n<li>-xor: ($x -eq $y -xor $i -ne $j)<\/li>\n<li>-not (expression):\u00a0 -not ($x -eq $y)\n<ul>\n<li>!(Expression): !($x -e1 $y)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>If \/ ElseIf \/ Else Statements<\/strong><\/p>\n<pre>if ($someVar -eq $anotherVar){\r\n  Write-Host \"Yay! They are the same!\"\r\n} ElseIf ($someVar -lt $anotherVar){\r\n Write-Host \"Whoops! $someVar is less than $anotherVar!\"\r\n} Else {\r\n Write-Host \"Wow! $someVar is greater than $anotherVar!\"\r\n}<\/pre>\n<p><strong>Switch Statements<\/strong><\/p>\n<pre>$cuteCrazy = \"Average\"\r\nSwitch($cuteCrazy) {\r\n  \"Cute\" {\r\n     Write-Host \"She's Cute\"\r\n     break\r\n  }\r\n  \"Average\" { Write-Host \"She's Average.\"; break }\r\n  \"Crazy\" { \r\n    Write-Host \"Stay away from that, bruh!\"\r\n    break\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Conditions Terrinaries -eq Equal To -ne Not Equal To -le Less than or Equal To -lt Less than -ge Greater than or Equal To -gt Greater than Boolians -and And: ($x -eq $y -and $i -ne $j) -or Or: ($x -eq $y -or $i -ne $j) -xor: ($x -eq $y -xor $i -ne $j) -not ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=3965\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82,83],"tags":[],"class_list":["post-3965","post","type-post","status-publish","format-standard","hentry","category-powershell","category-programming"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/3965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3965"}],"version-history":[{"count":1,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/3965\/revisions"}],"predecessor-version":[{"id":3966,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/3965\/revisions\/3966"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}