在我的腳本中,我需要知道帳戶是否爲Mail-User
,Mail-Contact
或許可的用戶帳戶。如何確定賬戶類型?
目前,我必須事先知道這一點,並自己提供給腳本。
有沒有比這更好的方法?這只是授權用戶和郵件聯繫人或郵件用戶之間的數字。
#test for existing account
function GetAccountType($whatusername){
$isType = [bool](get-mailbox -identity $whatusername -ErrorAction SilentlyContinue)
if($isType){
$thisType = "Licensed"
}else{
$isType = [bool](get-mailuser -identity $whatusername -ErrorAction SilentlyContinue)
if($isType){
$thisType = "Mail-Contact"
}
}
return $thisType
}
這很完美 - 一行代碼可以完美實現。 – bgmCoder
這甚至得到SharedMailbox – bgmCoder
是的。它確實..我想現在你可以寫出基於此的條件。否則我會坐在它上面,但我需要爲這種情況首先設置環境。 :) –