Scrip to update Sharepoint Online content type

I have a content type "TestContentType" with three columns:
Document Type
Category
Sub-category
This content type is used on 18 document libraries, in 3 site collections.
The Category column needs to have a "description" added which currently has no description. Is there a way to achieve this via a script so I don't have to make change manually via the UI.
So far I have come up with the following script, but this so far only lists all list and document libraries. What I actually need is to be able to get the content type in this case "TestContentType" and then update the "Category" column
to include a description:
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
$webUrl = Read-Host -Prompt "HTTPS URL for the SP Online 2013 site"
$username = Read-Host -Prompt "Email address login"
$password = Read-Host -Prompt "Password for $username" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$web = $ctx.Web
$lists = $web.Lists
$ctx.Load($lists)
$ctx.ExecuteQuery()
$lists| select -Property Title
Any suggestions would be appreciated.

This isn't the best way to do it, which would be manipulating SharePoint through the CSOM, however you can automate IE so that it runs through a series of actions.
The nice way would be to use something like the client-side code here:
https://sharepointpowershell.codeplex.com/
 I don't have the time to dig into it at the moment but i'd try to merge that CSOM approach with something like this script:
http://get-spscripts.com/2010/11/add-and-remove-site-content-types-from.html which uses the on-prem version.

Similar Messages

  • Multiple "Workflow Task (SharePoint 2013)" content type found

    Users on one specific sub-site reported that they are unable to add site columns to content type. When user clicks "add existing site column" user get error message - upon looking up on ULS, it indicate there were duplicate column "System.ArgumentException:
    No two choices should have the same ID". I came across similar issue on different site before and resolved it by deleting duplicate column, plus that site column was not used on any list or associated with any content type but this time duplicate
    column is "Task outcome" column which is associated with "Workflow Task(SharePoint2013)" content type. So looking up these two specific site column and content type I noticed there are 8 occurrence of each at affected site
    level (see below on image).
    Similarly there are 8 "Task Outcome" columns under Site Columns. So I refreshed staging env with prod copy and tried to delete "Workflow Task(SharePoint 2013" content type and got error message as shown below. Under Site features, I noticed
    "SharePoint 2013 Task List" feature was enabled, hoping this will do the trick I disabled it as we still use SharePoint 2010 workflows, but to no avail.
    Sorry, something went wrong
    The content type "Workflow Task (SharePoint 2013)" is part of an application feature.
    Not sure how it got started and something will try to find out but any advise on how to fix this issue?
    Thanks,
    MK Sin

    Hi Sin,
    According to your description, my understanding is that the users got an error when clicking “add existing site column”.
    For deleting the duplicate “Task outcome”column, you need to go to the “Workflow Task(SharePoint 2013)” content type, click the “Task outcome” column, and remove it from the content type.
    Then go to site columns, find the duplicate columns, and delete them and make sure only one “Task outcome” column exists.
    After the above, re-add the “Task outcome” into the “Workflow Task(SharePoint 2013)” content type.
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Custom Property in Microsoft Word 2010 Document Template and Sharepoint 2010 Content Type not Syncing up

    I wrote a macro in a Word 2010 template with a custom property called HeaderFooter (a Yes/No value). When the property is changed to No, the header and footer are hidden, otherwise, the header and footer are displayed.
    I added the template to a SharePoint 2010 Document library, with a content type DocInformation and a column name HeaderFooterOffOn that I want to map to the custom property HeaderFooter in the Word Document.
    The macro isn't working in SharePoint, though, because when the user clicks on the HeaderFooterOffOn in the DIP of the Word Document, the Word Custom Property (HeaderFooter) isn't changing with it.
    How do I get these two synced up, so that when the SharePoint column is changed, the Word Document's custom property simultaneously updates with it?

    Hi kevinkevinc,
    There is no direct way to run macro in SharePoint
    As a workaround, I suggest you use SharePoint Event Receiver to run some custom code when column changed.
    Here is a similiar thread for your reference:
    http://social.msdn.microsoft.com/Forums/office/en-US/249249e2-3263-4001-86fa-bda342d95f35/run-word-macro-on-newly-uploaded-sharepoint-word-documents?forum=sharepointdevelopmentlegacy
    More information:
    SharePoint Event Receiver:
    http://msdn.microsoft.com/en-us/library/ee231563.aspx
    http://msdn.microsoft.com/en-us/library/ff398052.aspx
    Best Regards
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Zhengyu Guo
    TechNet Community Support

  • Deleting sharepoint list content type Fields

    Hi
    Please tell me the code for deleting all the fields inside content type fields..This is my code i used,but its not deleting the fields.
     SPSite spsite = new SPSite("http://ghfjhhk18:8001");
                SPWeb web = spsite.OpenWeb();
                web.AllowUnsafeUpdates = true;
                SPList list = web.Lists["Test"];
                SPContentTypeCollection cts = list.ContentTypes;
                SPContentType ct = cts["Item"];
               // ct.FieldLinks.Delete("Expires");
                //ct.Update();
                SPFieldCollection contentTypeFieldCollection = ct.Fields;
                foreach (SPField spField in contentTypeFieldCollection)
                    if (ct.Fields.ContainsField(spField.Title))
                        //SPFieldLink fieldLink = new SPFieldLink(spField);
                        ct.FieldLinks.Delete(spField.Title);
                    //myContentType = null;
                ct.Update();
                web.AllowUnsafeUpdates = false;
            }but this code is not deleting the fields..
    pls help me as soon as possible.
    One friend told me to do for loop in reverse..but how can i accomplish that

    Hi,
    Please refer the below code snippet which may help you to fix your issue. If not please refer the below links also
    http://ptsharepoint2010.blogspot.in/2011/12/programmatically-remove-fields-from.html
    http://www.c-sharpcorner.com/uploadfile/54db21/delete-field-content-type-in-sharepoint-2010-programmaticall/
    using (SPWeb web = site.OpenWeb())
    SPList spList = web.Lists["<ListName>"];
    SPContentTypeCollection spCTS = spList.ContentTypes;
    SPContentType spCT = spCTS["YourContentType"];
    spCT.FieldLinks.Delete("YourField");
    spCT.Update();
    If its not helping you, please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • Error after updating field and content type

    Hi,
    I have a feature with a custom list and content type.
    I changed one field type from Text to Note, and made the same change in my Schema.xml file.
    But after deploying I get an error when I visit my list.
    "The file name you specified could not be used.  It may be the name of an
    existing file or directory, or you may not have permission to access
    the file".
    I have several sites with the same list, and all gives the same error.
    What I understand from the ULS logs it can't find my schema file, but when I look at the 14 hive it is there.
    ULS
    Failed to open the file 'schema.xml'.
    Failed to retrieve the list schema for feature {4D3315CB-7F20-4DB3-9CB3-258AC110F9BC}, list template 21973; expected to find it at: "".
    Any ideas about how to fix this?
    The text expected to find it at: "" can be the problem as I have my schema file in a folder named Correspondence List.
    And in the 14 hive I find the schema at 14\TEMPLATE\FEATURES\my feature\Correspondence List\Schema.xml
    This is from my manifest file:
    <ElementManifest Location="Correspondence\Elements.xml" />
    <ElementManifest Location="Correspondence List\Elements.xml" />
    <ElementFile Location="Correspondence List\Schema.xml" />
    Any help are appriciated

    Hi,
    Any update?
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Customising a SharePoint list content type form - "Manage multiple list items with this form"

    I have designed a form for a content type on an existing SharePoint list.  When I ran the initial wizard, I selected
    Manage multiple list items with this form which is great, exactly what I want.
    But, there are some columns in this content type that I do not want repeating and have them moved them outside of the Repeating Section but I am getting the below error.  I can't seem to find a way to create a new non-repeating group though.  Any
    advice on how to do this?

    *Bump*

  • Update Item when Content Type is changed in the browser

    I feel like I might be missing something obvious here - I set up a number of managed content types.  While editing a list item with multiple content types, when a user changes to a different content type using the drop down at the top of the page,
    the edits are not saved.  Is there any way to force an update when the user changes content type?  Clicking save returns the user to the list view which means the user needs to edit it again, and navigate to the content type.

    Hi Steve,
    Per my understanding, you might want to update item with the input values when content type changed by selecting an option in the “Content Type” drop down menu in
    EditForm.aspx page.
    A Content Type is a set of predefined columns, from the perspective of the use of Content Type in a list, it would be easier to maintain per record with only one content
    type as an item, this is also a recommended behavior when working with multiple content types in a list.
    If you want to take use of columns from multiple content types in an item, a suggestion is that you can create a custom content type with the columns from other content
    types you want, then add it into your list.  
    Thanks 
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint 2010 Content Type Hub

    Hi,
    I have a Content Type Hub in the SharePoint Server and it is being subscribed to one of the Web application and it’s site collections.
    If I make any changes in existing column of the Content Type in Content Type Hub and subscribe to the required site collection, the changes are not being propagated to libraries columns which are part the attached Content Type from the Conte Type Hub.
    But the Content Types are being subscribed and changes are available at Site column of the Subscribed Sites but not in the existing Library level.
    If I add the New column in CT hub and the new column appears in the existing Library of the subscribed sites.
    Please assist me how can I propagate the Content Type changes from CT Hub to the existing Library of the subscribed site?
    Regards,
    Vidya Lokesh

    It's a known issue.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/b865e6a0-39d8-4aae-9df6-f07ff9d1d96c/content-type-changes-are-not-reflected-in-subscribing-document-libraries?forum=sharepointgeneralprevious
    MS chose to avoid pushing down to lists and libraries, presumably to avoid people trashing their systems by making silly changes and pushing them down to thousands of lists and libraries.
    The only surefire way is to delete the CT from the list/library and re-add it. You could script something up to do that I guess but I don't know of any examples of it floating about.
    PS. You're in the wrong forum, this relates to 2010 not 2013, although in this case that's not a major issue.

  • SharePoint 2007 - Content Type Usage

    My question relates to Content Type Usage.  I am helping to develop a customer facing SharePoint site template for my company.  The main purpose of the site is to track the ERP Software Implementation process from start to finish.
    I created a new task list which includes all the stages and activities within the project schedule of the implementation.  I then created a calendar View of this task list so that customers can view it in calendar form. 
    The issue that I am running into is that the Task List Item Content Type doesn't include the All Day Event column and so the items on the calendar view of the task list are not displaying properly (they end the day before vs the day of).  I found that
    I need to add the Event Content Type in order to utilize the All Day Event column.  I added the Event Content Type and now have found that's it's an either/or situation.  I can either create a New Event or a New Task.
    Long question short, is there a way that I can "merge" content types so that the Task content type includes the All Day Event column?

    Columns form part of content types, which you know.  What isn't clear is that there is a _hidden group of columns that don't appear in the SharePoint GUI.  The All Day Event is one of them.  If you were to download
    SharePoint Manager 2007 you could find the property and change it's group.  Here's a screenshot of what you'd need to change
    You'd navigate something like Farm --> Services --> Web Applications --> <Your Web App> --> <Site Collection> --> Fields.
    I normally move items from the _Hidden group to the Custom Columns grouping. This will then make it available for addition within the Content Type that you've made.
    Hope that helps.
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Sharepoint Online - Content Search, some Display Templates missing.

    I'm experimenting Content Search web parts in a number of Site Collections, but appear to be getting different Display Templates available.
    Can anyone explain what controls the availability of the templates please...
    Our Default root site collection.
    http://company.sharepoint.com
    Has Web part controls of
    List & Slideshow
    And Item Templates of
    Large Picture, Picture on left 3 lines, Recommended Items & Video
    All other site collections  http://company.sharepoint.com/sites/Dept1
    Has Web part controls of List
    & Slideshow
    PLUS List with Paging
    And Item Templates of
    Large Picture, Picture on left 3 lines, Recommended Items & Video
    PLUS Diagnostic, Picture on Top 3 Lines bottom, & Two Lines
    I've compared site and collection features and cannot see any features that would appear to control this...
    Any ideas.... Please!
    Cheers
    Russ

    I just had the same issue, I think it was something with broken upgrade code from 2013.
    Anyways, I solved it:
    Go to Master Page Gallery --> Display Templates --> Content Web Parts
    Delete all JavaScript Files in there except the Group_Content.js (!!!), they seem to have messed up metadata (Content Type Reference and Template Level)
    Open up PowerShell and issue this command:
    Get-SPFeature SearchTemplatesandResources | Enable-SPFeature -Url [URLtoBrokenSite] -Force
    This will re-upload the JavaScript files and all controls and templates finally are there again, hopefully ;)
    // Tried and true method for weather forecasting - random numbers. String weather = (new Random()).Next(2)==0?"rainy":"sunny";

  • How to Enforce Sharepoint 2013 content type validation rules when modifying document using Word 2013

    Good day,
    I have two date columns (Start Date and End Date) in a content type in Sharepoint 2013.  A file library uses this content type.
    In the document template I have the two dates (Start Date and End Date) showing in the Document Panel.  I can edit them well enough and they show in the document correctly.
    In the content type I have validation rules that the End Date must be greater than the Start Date. 
    The question is, how can I enforce this validation on the client side in Word.  Is there anyway to achieve this?
    The user will not have access to change the document properties in Sharepoint. (Not my call)
    Thank-you!

    The "panel" is called the Document Information Panel in SharePoint. You can customize this using InfoPath from the page where you created / edited your Content Type. Go to Settings, Site Settings Content Types, edit your content type, click Document
    Information Panel and then click "Edit this template". In InfoPath you can create a Rule to enforce your dates.
    This may require the Enterprise Edition of SharePoint to support the InfoPath Forms Services.
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • SharePoint Online content effective permissions DO NOT match check permissions

    I have a document list in the main site. The contents are sensitive so inheritance has been broken.
    Access to the list is via two AD groups: ADGroupEdit and ADGroupRead
    The list contains several documents. I have selected a document and gone to the advanced view of permissions
    This correctly shows the permissions:
    ADGroupRead    Domain Group     Read
    ADGroupEdit     Domain Group     Edit
    UserA is a member of ADGroupRead and UserB is a member of ADGroupEdit. UserA and UserB are members of only one AD group.
    From the same view, I can click 'check permissions'. Both UserA and UserB show the correct permissions via the correct group.
    However, when UserA attempts to access the content via OneNote (either the App or Online) they only see some of the files, and the level of access varies between Read and Edit. I have checked the individual file permissions which are set to inherit and display
    the correct permissions.
    The problem appears to be that permissions are not been interpreted correctly when listing files.
    Does anyone have any ideas why this is happening?

    Hi signalwarrant,
    Whether you are using Claims authentication.
    The claims based token is refreshed every 10 hours and hence if you make any changes to Active directory group memberships it won't reflect immediately in the token. you need to run the following powershell command to adjust the token life time to a smaller
    value.
    $sts = Get-SPSecurityTokenServiceConfig
    $sts.WindowsTokenLifetime = (New-TimeSpan –minutes 60)
    $sts.FormsTokenLifetime = (New-TimeSpan -minutes 60)
    $sts.Update()
    IISRESET
    More information, please refer to the link:
    http://www.shillier.com/archive/2010/10/25/authorization-failures-with-claims-based-authentication-in-sharepoint-2010.aspx
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • SharePoint associating content type with Reusable workflow gives error

    System.NullReferenceException: Object reference not set to an instance of an object.  
    at ASP._layouts_addwrkfl_aspx.__Render__control2(HtmlTextWriter __w, Control parameterContainer) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\AddWrkfl.aspx:line 157   
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)   
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)   
    at System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer)   
    at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)   
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)   
    at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)   
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)   
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)   
    at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.RenderChildren(HtmlTextWriter writer)   
    at System.Web.UI.Page.Render(HtmlTextWriter writer)   
    at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.Render(HtmlTextWriter writer)   
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Guneet Kalra

    Hi Guneet,
    Thanks for your post.
    I am trying to involve someone familiar with this topic to further look at this issue.
    Best Regards.
    Kelly Chen
    TechNet Community Support

  • Updating SharePoint online teamsite list with Project name from Project center (Project online)

    Hi,
    I would like to have the name of the project on a teamsite list automatically when a new project is published. Any workaround or best practice suggestion is highly appreciated. Thanks
    I have Office 365 E4 subscription, fyi.
    Ashraf
    www.MrOffice365.com

    Hi Ashraf,
    I'm not sure if it answers your need, but you could add the site list webpart on the PWA home page (or in any other PWA page):
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Content Types updates not getting pushed to Lists/Libraries Sharepoint 2013

    Hello,
    We have updated Content Type at Content Type Hub(ex. Making columns Hidden/Req...etc..). These changes are pushed to the consumer sites site level Content types but the problem is these changes are not reflecting at List/Library level Content type.
    Is there a way to explicitly push down the changes ?
    Best Regards, Pankaj Rana

    http://sharepoint.stackexchange.com/questions/52259/how-to-update-a-deployed-content-type
    perform the changes to the ContentType make sure to push changes to the lists while updating the ContentType.
    For now, you might need to perform some clean-up job here, just to make sure the field is deleted from all the lists, with your Custom ContentType. Use the following PowerShell script for clean-up! Vårsegod :)
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    $site = Get-SPSite "http://your.site.com"
    foreach($web in $site.AllWebs)
    #iterates through all the Lists
    for ($i = 0; $i -lt $web.Lists.Count; $i++)
    $list = $web.Lists[$i];
    $MyListContentTypes = $list.ContentTypes
    if ($MyListContentTypes -ne $null)
    $ct = $list.ContentTypes["You Desired Content Type Name"]
    if($ct)
    Write-Host "In list Content Type and deleting the field" $ct.Fields["You Field Name"].Id;
    $ct.FieldLinks.Delete($ct.Fields["You Field Name"].Id)
    $ct.Update()
    Edit: How to push down changes to all the Content types via SharePoint Server Object Model:
    using (SPWeb oWebsite = new SPSite("http://MyServer/sites/MySiteCollection/MyWebSite").OpenWeb())
    SPList oList = oWebsite.GetList("MyWebSite/Lists/MyList");
    SPFieldCollection collFields = oWebsite.Fields;
    string strNewColumn = collFields.Add("MyNewColumn", SPFieldType.Text, false);
    SPFieldLink oFieldLink = new SPFieldLink(fields[strNewColumn]);
    SPContentType oContentType = oList.ContentTypes["Specification"];
    oContentType.FieldLinks.Add(oFieldLink);
    oContentType.Update(true);
    Edit 2: Update a Content Type using PowerShell:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    //get the specific Root web
    $spweb= Get-SPWeb "http://your.site.com"
    //get the fields collection
    $fields = $spWeb.Fields
    //get the specific field
    $field = $fields.GetFieldByInternalName("Name of you field")
    //get the specific Content Types from Root Web
    $contentType = $spWeb.ContentTypes["You Content Type"]
    //delete a field from a Content Type
    $contentType.FieldLinks.Delete($field)
    //add a field to a Content Type
    $contentType.FieldLinks.Add($field)
    //update the Content Type and push changes to the children
    $contentType.Update($true)http://sharepoint.stackexchange.com/questions/42744/how-to-add-a-field-to-a-contenttype-with-feature-upgrade-for-new-and-existing-shttp://msdn.microsoft.com/en-us/library/office/aa543504%28v=office.14%29.aspx
    If this helped you resolve your issue, please mark it Answered

Maybe you are looking for

  • Getting files bigger than 4GB onto external drive for itunes

       Im woundering if anyone can help me ?     I have recently purchased a 2012 mini mac and wanted to transfer my itunes from my pc to the new mac.    After several attempts at doing this i found it easier to start afresh due to my external hdd that i

  • About Infotype Creation in ECC6.0

    Hi All Actually my requirement is create a custom infotype and use this infotype in pa30.Buy i am using ecc6.0 version. I know in 4.7 version only. Try to send me steps about create infotype in ecc6.0 version.it is very urgent requirement. Regards ha

  • How to Call Crystal Reports from Swing Application

    Hi All, I have a requirement for calling Crystal Report from Swing Application. Please let me know how can I do that, and also provide the Source code for calling the crystal report. Thanks in advance. Chandra

  • InvokeLater

    I have read the documents about the EDT. So I have a simple question: Suppose you have a JFrame which contains just one JLabel. Your application has a thread that receives datagrams from the net. You want your JLabel to display the number of packets

  • Wireless Canon printer problem - solved

    My household has 2 MacBook Pros that suddenly stopped being able to print to my Canon MX870 printer/multi-function device wirelessly ("Support code: 300" was the error message I got). After many hours of the chicken dances of turning things off and o