I am new to SharePoint and CSOM, but I am comfortable in PowerShell and .NET. I’m trying to do the following tasks in SharePoint Online:
- Get the list of users in a particular named group
- For each user, create a folder
- For each folder created, break inheritance with the parent folder and assign exclusive access to its respective user
For the first task, I’ve tried the following code:
# Get a specific group by name $ allGroups = $ web.SiteGroups $ ctx.Load($ allGroups) $ ctx.ExecuteQuery() $ group = $ allGroups.GetByName('My Group') # Get all users in the group 'My Group' $ users = $ group.Users $ ctx.Load($ users) $ ctx.ExecuteQuery()
GroupCollection.GetByName method always gives me a “collection has not been initialized” error. I know that
$ allGroups is initialized because I am able to query other properties such as
$ allGroups.Count. What am I doing wrong? Is there another way to retrieve a particular group by name?
The second task should be straightforward. I already have successfully created new folders, so I just need to use a foreach loop to accomplish this step.
I haven’t been able to test the third task yet, but I have seen plenty of code samples online for breaking inheritance, and I expect that adding a permission for a user won’t be too difficult. I’ll edit this question if I run into problems, but in the meantime, some sample code to get me started would be very appreciated.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!