Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu makalede, Microsoft Entra PowerShell kullanarak Microsoft Entra ID grupları yönetmeyi öğreneceksiniz. Gruplar oluşturma ve güncelleştirme, kullanıcı ve sahip ekleme, sahipsiz ve boş grupları sorgulama örnekleri verilebilir.
Prerequisites
- Microsoft Entra kullanıcı hesabı. Henüz bir hesabınız yoksa ücretsiz olarak bir hesap oluşturabilirsiniz.
- En son Microsoft Entra PowerShell modülünü yükleyin. Daha fazla bilgi için bkz. Microsoft Entra PowerShell modülünü yükleme.
- En azından Gruplar Yöneticisi rolüne sahip olun.
Grup oluşturma
Grup oluşturmak için, grup oluşturmak için gerekli izinlere sahip olduğunuzdan emin olun.
Connect-Entra -Scopes 'Group.ReadWrite.All'
Yeni bir grup oluşturmak için aşağıdaki komutu çalıştırın.
$groupParams = @{
DisplayName = 'Contoso marketing'
MailEnabled = $false
SecurityEnabled = $true
MailNickName = 'NotSet'
}
New-EntraGroup @groupParams
DisplayName Id MailNickname Description GroupTypes
----------- -- ------------ ----------- ----------
Contoso marketing aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb NotSet {}
Bu komut, adlı Contoso marketingyeni bir grup oluşturur.
Aşağıdaki komutu kullanarak oluşturulan grubu arayın.
Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
DisplayName Id MailNickname Description GroupTypes
----------- -- ------------ ----------- ----------
Contoso marketing aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb NotSet Contoso marketing EMEA {}
Bu komut, yeni oluşturulan grubun ayrıntılarını döndürür. Grubu aramak, güncelleştirmek veya silmek için de (GUID) kullanabilirsiniz GroupId .
Grup ayrıntılarını güncelleştirme
Aşağıdaki komutu çalıştırarak grup açıklamasını güncelleştirin.
Get-EntraGroup -Filter "displayName eq 'Contoso marketing'" | Set-EntraGroup -Description 'Contoso marketing Global'
Güncelleştirilmiş açıklamayı onaylamak için Get-EntraGroup'u yeniden çalıştırın.
Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
Gruba kullanıcı ekleme
Aşağıdaki komutu çalıştırarak gruba bir kullanıcı ekleyin.
GroupId, Grup Kimliği ve MemberId Kullanıcı Kimliği'dir. Kullanıcı Kimliğini Microsoft Entra yönetim merkezi veya Get-EntraUser komutunu çalıştırarak alabilirsiniz.
$group = Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
$user = Get-EntraUser -UserId 'SawyerM@contoso.com'
Add-EntraGroupMember -GroupId $group.Id -MemberId $user.Id
Grup üyelerini almak için komutunu kullanın:
$group = Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
Get-EntraGroup -GroupId $group.Id | Get-EntraGroupMember | Select-Object Id, DisplayName, '@odata.type'
Id DisplayName @odata.type
------------------------------------ ----------------- -------------------------------
dddddddd-3333-4444-5555-eeeeeeeeeeee Sawyer Miller #microsoft.graph.user
eeeeeeee-4444-5555-6666-ffffffffffff Alex Wilber #microsoft.graph.user
aaaaaaaa-6666-7777-8888-bbbbbbbbbbbb My Application #microsoft.graph.servicePrincipal
cccccccc-8888-9999-0000-dddddddddddd Contoso Group #microsoft.graph.group
Kullanıcıyı grup sahibi olarak ekleme
Aşağıdaki komutu çalıştırarak gruba grup sahibi ekleyin.
GroupId, Grup Kimliği ve OwnerId Kullanıcı Kimliği'dir.
$group = Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
$owner = Get-EntraUser -UserId 'AdeleV@contoso.com'
Add-EntraGroupOwner -GroupId $group.Id -OwnerId $owner.Id
Güncelleştirilmiş grup sahibini onaylamak için komutunu kullanın:
$group = Get-EntraGroup -Filter "displayName eq 'Contoso marketing'"
Get-EntraGroup -GroupId $group.Id | Get-EntraGroupOwner | Select-Object Id, DisplayName, '@odata.type'
Id DisplayName @odata.type
------------------------------------ ----------------- ---------------------------
aaaaaaaa-6666-7777-8888-bbbbbbbbbbbb Adele Vance #microsoft.graph.user
Sahipsiz veya boş grupları sorgulama
Sahipsiz grupları sorgulamak için aşağıdaki komutu çalıştırın.
$allGroups = Get-EntraGroup -All
$groupsWithoutOwners = foreach ($group in $allGroups) {
$owners = Get-EntraGroupOwner -GroupId $group.Id
if ($owners.Count -eq 0) {
$group
}
}
$groupsWithoutOwners | Format-Table DisplayName, Id, GroupTypes
DisplayName Id GroupTypes
----------- -- ----------
Contoso marketing aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb {}
HelpDesk admin group eeeeeeee-4444-5555-6666-ffffffffffff {}
Üyeleri olmayan grupları (boş gruplar) sorgulamak için aşağıdaki komutu çalıştırın.
$allGroups = Get-EntraGroup -All
$groupsWithoutMembers = foreach ($group in $allGroups) {
$members = Get-EntraGroupMember -GroupId $group.Id
if ($members.Count -eq 0) {
$group
}
}
$groupsWithoutMembers | Format-Table DisplayName, Id, GroupTypes
DisplayName Id GroupTypes
----------- -- ----------
Contoso marketing aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb {}
HelpDesk admin group eeeeeeee-4444-5555-6666-ffffffffffff {}
Kaynakları temizle
Grubu kaldırmak için komutunu kullanın:
Get-EntraGroup -Filter "displayName eq 'Contoso marketing'" | Remove-EntraGroup