0
In my other question私はユーザーアカウントの種類を決定する方法を尋ねました。しかし、今私はどのような種類のグループがあるのかを発見する必要があります。グループタイプの決定方法
ユーザーをグループに追加する関数を作成しています。問題は、ユーザーを追加する前にどのような種類のグループであるかを知る必要があることです。これは、中規模のo365グループ、セキュリティグループ、配布リスト、またはメールが有効なセキュリティグループである可能性があります。
だから、私はこのような何かやってる:
function GetGroupType([string]$groupname){
#You can use get-group on any group, but the 'grouptype' results are not very descriptive
#mesg = "Universal, SecurityEnabled"
#o365 = "Universal"
#Distribution = "Universal"
$thisgrouptype = get-group -identity $groupname -ErrorAction SilentlyContinue | select grouptype
if($thisgrouptype.contains("Universal"){
if($thisgrouptype.contains("SecurityEnabled"){
$grouptype = "mesg"
}else{
#since you can't run get-unifiedgroup against a security/distribution group, we should get "Universal" for the return value
$thisgrouptype = get-unifiedgroup -identity $groupname -ErrorAction SilentlyContinue | select grouptype
if($thisgrouptype -eq "Universal"){
$grouptype = "o365"
}else{
$grouptype = "distribution"
}
}else{ #if it doesn't have "Universal" then it's not what we are looking for
$grouptype = ""
}
return $grouptype
}
#try to add a user to a group
$grouptype = GetGroupType $groupname
switch($grouptype){
"o365"{Add-UnifiedGroupLinks -identity "$whatgroupname" -LinkType Members -Links "$whatusername" }
"mesg"{Add-DistributionGroupMember -Identity "$whatgroupname" -Member "$whatusername" }
}
をしかし、これに伴う問題は、私は、私はグループに作用することができます前に、それがグループの種類を知っていなければならないということです。
私はどのような種類のグループを見つけることができますか?