Created
May 22, 2017 21:51
-
-
Save RichieBzzzt/4061686751e1d272c70cacd96ed93200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$my_variable = "this is the value of my_variable" | |
if (Test-Path variable:my_variable) { | |
Write-Host $my_variable -ForegroundColor Magenta -BackgroundColor Yellow | |
} | |
else { | |
Write-Host 'Variable $my_variable does not exist.' -ForegroundColor Yellow -BackgroundColor Magenta | |
} | |
#note: my_non_existent_variable doesn't exist, so will go to else statement | |
if (Test-Path variable:my_non_existent_variable) { | |
Write-Host $my_non_existent_variable -ForegroundColor Magenta -BackgroundColor Yellow | |
} | |
else { | |
Write-Host 'Variable $my_non_existent_variable does not exist.' -ForegroundColor Yellow -BackgroundColor Magenta | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment