So for the past couple weeks, I've been playing around with a few powershell scripts. Currently I've been working with get-CASmailbox. I'm trying to get this script to check the status of activesync and for any disabled protocol's (imap, pop, mapi, etc.) and prompt to turn it on using set-CASmailbox if it detects that any are disabled.
I've got no problem running get-CASmailbox, it returns the exact information I'm looking for, but I'm having a little bit of trouble with "If" statements to get this script working.
Figured I would start light and just have an "If ($actsync -eq "False") {Write-Host 'n'n "Activesync is disabled"}" message pop up. I can work the set prompt later but I cannot for the life of me get the parameter to return as just "False" (at least that's what I've gathered so far.)
I've tried pulling the boolean using the following and I have been unsuccessful.
$actsync = (get-casmailbox $user).activesyncenabled
If ($actsync -eq "False") { Write-Host "Activesync is disabled" -ForegroundColor Red} oddly enough this will only write back "Activesync is disabled" when activesync is enabled, ie "ActiveSyncEnabled = true" I've tried flipping if $actsync -eq "True" but this did not provide results
and
$actsync2 = (get-casmailbox $user | fl *ActiveSyncEnabled*)
followed then by the if statement above
If I can at least get this to accurately write back "activesync is disabled" when activesync is disabled, then I should be well on my way to figuring this out, can anyone point me in the right direction?