|
|
This script doesn't work for me. I have tried to run it and also step through to debug it. The problem appears to be related to this $ctx=New-Object Microsoft.SharePoint.Client.Cl ientContext($Ur l) $ctx.Credential s = New-Object Microsoft.Share Point.Client.Sh arePointOnlineC redentials($Use rname, $azurepassword) $ctx.Load($ctx. Web.Lists) $ctx.Load($ctx. Web) $ctx.Load($ctx. Web.Webs) $ctx.ExecuteQue ry() When I run "$ctx.Web" I get the error above I have done some additional internet searches and found the following links http://sharepoi nt.stackexchang e.com/questions /44100/powershe ll-and-the-clie nt-object-model -the-collection -has-not-been-i nitialized http://sharepoi nt.stackexchang e.com/questions /44100/powershe ll-and-the-clie nt-object-model -the-collection -has-not-been-i nitialized In both cases it appears that you need to explicitly call but I am not really sure what that means. any help would be appreciated. Thank you Chris
Have you inserted your data at the end of the script? What url are you using, can you post it here? Which line exactly gives you the error?
On re-reading your question - I know you probably won't come back here, Clearwaterms, but maybe it will help the others. You cannot output $ctx.Web, because not all of its properties have been initialized. One of these properties is a collection (e.g. Alerts, RssFeeds) and it is throwing you this error. If you want to display a particular property of the web object, you can do it in the following way: Write-host $ctx.Web.Created For some of the properties, you may need to load them first, e.g. $fields=$ctx.We b.Fields $ctx.Load($fiel ds) $ctx.ExecuteQue ry() Write-output $fields
Thank you so much for your scripts, I use them a lot! I really need to break inheritance with one of my (LARGE) lists, but can't figure it out. Is there any way to specify 1 list, not all?
Hi Brock Albitz, I created here a version that breaks inheritance only for one list. Have a look and let me know if this is what you are looking for: https://gallery.technet.micros oft.com/office/ Break-role-inhe ritance-for-6c6 534b8
PS C:\Users\xxxxxx\Downloads> C:\Users\xxxxxx \Downloads\SetU niquePermission s for all lists.ps1 Exception calling "ExecuteQuery" with "0" argument(s): "Method not found: 'Boolean System.Net.WebR esponse.get_Sup portsHeaders()' ." At C:\Users\xxxxxx \Downloads\SetU niquePermission s for all lists.ps1:23 char:3 + $ctx.ExecuteQue ry() + ~~~~~~~~~~~~~~~ ~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocatio nException + FullyQualifiedE rrorId : MissingMethodEx ception https://xxxxxx. sharepoint.com The type initializer for 'Microsoft.Shar ePoint.Client.R esources' threw an exception. At C:\Users\xxxxxx \Downloads\SetU niquePermission s for all lists.ps1:26 char:12 + foreach( $ll in $ctx.Web.Lists) + ~~~ + CategoryInfo : OperationStoppe d: (:) [], TypeInitializat ionException + FullyQualifiedE rrorId : System.TypeInit ializationExcep tion