Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 如何确定帐户类型?_Powershell_Office365 - Fatal编程技术网

Powershell 如何确定帐户类型?

Powershell 如何确定帐户类型?,powershell,office365,Powershell,Office365,在我的脚本中,我需要知道帐户是邮件用户、邮件联系人还是许可用户帐户 目前,我必须事先知道这一点,并提供给脚本自己 还有比这更好的方法吗?这仅适用于许可用户和邮件联系人或邮件用户之间 #test for existing account function GetAccountType($whatusername){ $isType = [bool](get-mailbox -identity $whatusername -ErrorAction SilentlyContinue)

在我的脚本中,我需要知道帐户是
邮件用户
邮件联系人
还是许可用户帐户

目前,我必须事先知道这一点,并提供给脚本自己

还有比这更好的方法吗?这仅适用于许可用户和邮件联系人或邮件用户之间

#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
}

我可能会查看
RecipientTypeDetails
以获取邮箱/邮件联系人的邮箱类型

如果你有更多的邮件联系人而不是邮箱来优化它,可能会做相反的事情

我猜“授权”是指用户邮箱?因为您没有提到Azure广告。在Azure广告中,您已通过
获取MsolUser
获得了
许可

function GetAccountType($user)
{
    $Mailbox = Get-Mailbox -identity $user | select name, RecipientTypeDetails
    $type = ""
    if ($Mailbox.RecipientTypeDetails -eq "UserMailbox")
    {
        $type = "Licensed"
    }
    elseif ($Mailbox.RecipientTypeDetails -eq "SharedMailbox")
    {
        $type = "Shared"
    }
    else
    {
        $MailUser = Get-MailContact -identity $user | select name, RecipientTypeDetails
        if ($MailUser.RecipientTypeDetails -eq "MailContact")
        {
            $type = "Mail-Contact"
        }
        else
        {
            $type = "Something else"
        }
    }
    $type
}

$a = GetAccountType -user "userid"
$a | Out-Host

我可能会查看
RecipientTypeDetails
以获取邮箱/邮件联系人的邮箱类型

如果你有更多的邮件联系人而不是邮箱来优化它,可能会做相反的事情

我猜“授权”是指用户邮箱?因为您没有提到Azure广告。在Azure广告中,您已通过
获取MsolUser
获得了
许可

function GetAccountType($user)
{
    $Mailbox = Get-Mailbox -identity $user | select name, RecipientTypeDetails
    $type = ""
    if ($Mailbox.RecipientTypeDetails -eq "UserMailbox")
    {
        $type = "Licensed"
    }
    elseif ($Mailbox.RecipientTypeDetails -eq "SharedMailbox")
    {
        $type = "Shared"
    }
    else
    {
        $MailUser = Get-MailContact -identity $user | select name, RecipientTypeDetails
        if ($MailUser.RecipientTypeDetails -eq "MailContact")
        {
            $type = "Mail-Contact"
        }
        else
        {
            $type = "Something else"
        }
    }
    $type
}

$a = GetAccountType -user "userid"
$a | Out-Host

RecipientTypeDetails指定返回的收件人类型

您可以使用“获取收件人”从以下值中进行选择:

  • 仲裁信箱
  • 会议室信箱
  • 接触
  • 发现邮箱
  • 动态分布组
  • 设备邮箱
  • 外部管理联系
  • 外部ManagedDistributionGroup
  • 法律信箱
  • 链接邮箱
  • 邮箱计划
  • 邮件联系人
  • 邮递联系
  • 邮件非通用组
  • MailUniversalDistributionGroup
  • MailUniversalSecurityGroup
  • 邮件用户
  • 公用文件夹
  • 角色组
  • 房间名单
  • 房间邮箱
  • 共享邮箱
  • 电子信箱
  • 系统邮箱
  • 使用者
  • 用户邮箱
  • 我从您的案例中了解到,您需要用户邮箱用户邮件用户邮件联系人

    我现在没有exchange设置。但你可以从这些价值出发。
    它属于Microsoft.Exchange.Data.Directory.RecipientTypeDetails[]

    RecipientTypeDetails指定返回的收件人类型

    您可以使用“获取收件人”从以下值中进行选择:

  • 仲裁信箱
  • 会议室信箱
  • 接触
  • 发现邮箱
  • 动态分布组
  • 设备邮箱
  • 外部管理联系
  • 外部ManagedDistributionGroup
  • 法律信箱
  • 链接邮箱
  • 邮箱计划
  • 邮件联系人
  • 邮递联系
  • 邮件非通用组
  • MailUniversalDistributionGroup
  • MailUniversalSecurityGroup
  • 邮件用户
  • 公用文件夹
  • 角色组
  • 房间名单
  • 房间邮箱
  • 共享邮箱
  • 电子信箱
  • 系统邮箱
  • 使用者
  • 用户邮箱
  • 我从您的案例中了解到,您需要用户邮箱用户邮件用户邮件联系人

    我现在没有exchange设置。但你可以从这些价值出发。

    它属于Microsoft.Exchange.Data.Directory.RecipientTypeDetails[]

    @bgmCoder,完成。MailContacts也应该如此。另外,
    RecipientType
    为许可用户和SharedMailbox返回
    UserMailbox
    ,这两者没有区别。我刚测试过。但是发现它是否是一个共享邮箱将使该功能变得完美。@dgmCoder,啊,好的。怎么样
    RecipientTypeDetails
    。应根据我的O365环境而有所不同。对不起-是的,对不起,我们正在使用Office365 online和Azure。啊!你用RecipientTypeDetails搞定了-就是这样@bgmCoder,完成。MailContacts也应该如此。另外,
    RecipientType
    为许可用户和SharedMailbox返回
    UserMailbox
    ,这两者没有区别。我刚测试过。但是发现它是否是一个共享邮箱将使该功能变得完美。@dgmCoder,啊,好的。怎么样
    RecipientTypeDetails
    。应根据我的O365环境而有所不同。对不起-是的,对不起,我们正在使用Office365 online和Azure。啊!你用RecipientTypeDetails搞定了-就是这样!这是完美的-一行代码就可以得到全部-完美。这甚至可以得到SharedMailboxYes。是的。。我想现在你可以根据这个写条件了。否则我会坐在上面,但我需要先为这个案例设置环境。:)是的,我试过了。这太棒了。谢谢你的回答。很高兴能帮你@bgmCoder:)这太完美了-一行代码就可以了-太完美了。这甚至可以共享MailboxYes。是的。。我想现在你可以根据这个写条件了。否则我会坐在上面,但我需要先为这个案例设置环境。:)是的,我试过了。这太棒了。感谢您的回答。很高兴帮助您@bgmCoder:)