When the Get-MBX function runs, no matter how I setup the If statement. It only runs the If code - or the Else code, but never either one or the other depending on what's selected. So my question is, what's the best way to evaluate a "String" in a If Loop?
I've tried using the following formats:
($EmailAddress -is "String")
($EmailAddress -eq $True)
($EmailAddress -is "String" -or $EmailAddress -eq $True)
($EmailAddress -is "String" -and $EmailAddress -eq $True)
($EmailAddress -match $EmailAddress)
####################################
# Exchange Online PowerShell Tasks #
# #
####################################
## Get-Mailbox Function ##
Function Get-MBX {
$EmailAddress = Read-Host "Are you look for a Specific Email Address? If not, just Press Enter. "
if ($EmailAddress -eq $True) {
Start-Transcript -Verbose
Get-Mailbox | Select EmailAddresses
Stop-Transcript
}
Else {
Start-Transcript -Verbose
Get-Mailbox
Stop-Transcript
}
}
$task_selection = Read-Host "What Task would like to perform? Select the number you would to run.
1: Get Mailbox List
"
switch ($task_selection) {
1 {Get-MBX
break}
Default {"End of Task"}