mardi 26 juillet 2016

If/Else Issue - PowerShell

I am building a script that'll check if ArchiveStatus for a O365 mailbox is active or not. I am able to pull the data but my if/else statement doesn't seem to work. I am a little new at using these statements so I am sure it is something simple that I am missing. This is what I have so far:

$Data=Get-Mailbox -identity "MailboxName" | ft name,*Archive*
$Data

if($_.ArchiveStatus -eq $True){Write-Host "Archive Enabled"}
else{Write-host "Archiving Disabled"}

No matter what mailbox i search up, the result is always "Archiving Disabled" even if the console shows user enabled. Any tips or tricks?

Thank You!

Aucun commentaire:

Enregistrer un commentaire