May 26, 2022

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

PowerShell (Part 5) – Security Groups

Now we can create start looking at the more serious stuffs, such as creating security groups and assigning users

1- Create a Security Group

In order to create a security group, we can simple do:

New-MsolGroup -DisplayName "SocialMedia" -Description "Social Media"

 

2- Retrieve a Security Group

We can either do a Get-MsolGroup which will list all the groups, or a better and cleaner way doing is by filtering by a specific keyword

Get-MsolGroup | Where-Object {$_.DisplayName -eq "SocialMedia"}

 

3- List a Security Group members

If you want to display the users in a certain Security Group, we can simply do:

$LogiSam = Get-MsolGroup | Where-Object {$_.DisplayName -eq "LogiSam"}
Get-MsolGroupMember -GroupObjectId $LogiSam.ObjectId

4- Add a member to a Security Group

In order to add a new member to an existing Security Group, we can do:

Leave a comment

You may have missed

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: