Trying to un-hide content type using powershell

I'm using this script below and am writing back the library name and if the content type is hidden after the update.
Everything points to being correct yet when I go back to the library settings the eDocument Link is still hidden. What am I missing?
add-pssnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$script:WebApps = Get-SPWebApplication "http://xxxx"
$script:DocLibType = [Microsoft.SharePoint.SPBaseType]::DocumentLibrary
foreach ($WebApp in $WebApps)
foreach ($site in $WebApp.Sites)
if ($site.AllWebs.Count -gt 0)
foreach ($web in $site.AllWebs)
foreach ($list in $web.GetListsOfType($DocLibType))
foreach ($ct in $list.ContentTypes)
if ($ct.Name.Equals("eDocument Link"))
$ct.Hidden=$false;
$ct.Update();
$List.Update()
Write-host "$site:: $web:: $List updated"
Write-host $ct.Hidden
$web.Dispose()
$site.Dispose()
SPSite Url=http://xxxx/team/is:: xxxx:: Active updated
False
SPSite Url=http://xxxx/team/is:: xxxx:: Documents updated
False

that's what you already checked in your loop 
if ($ct.Name.Equals("Wibble"))
the updated is because you already added the new content type at the start of the new item menu so this will make sure that you will add it to the end and ignore the first entry as if you add list contains duplicate content type you will get exception at
the line 
$list.RootFolder.UniqueContentTypeOrder=$ct_list
Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

Similar Messages

  • Deploying a Reusable Workflow to a List Content Type using PowerShell

    We have a situation where deployment of a reusable workflow for a site content type cannot be completed through the web interface due to the number of libraries where the content type is in use (time-out on deploy and update).
    It was hoped that this could be accomplished with PowerShell but the method of deploying to a list content type appears to be different than it is to a list (all content types).
    The below snippet works fine for a list / all content types:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.AddWorkflowAssociation($association)
    $_.Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    However changing the association as follows causes the script to still execute without a problem but the workflow doesn't appear for the content and the associations collection is empty:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    The only change is:
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    But unlike the list version, the association doesn't appear to be saved and no error is generated.
    Is anyone aware of what may cause this or have an example in C# that may explain something my script is missing?

    Hi Garry,
    After you associate the workflow to the content type, you should update the update the content type using
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
     method.
    Here is the completed script:
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site=Get-SPSite "http://serverName"
    $web=$site.OpenWeb()
    $list=$web.Lists["ListC"]
    $taskList=$web.Lists["Tasks"]
    $historyList=$web.Lists["Workflow History"]
    $ct=$list.ContentTypes["Link"]
    $culture=New-Object System.Globalization.CultureInfo("en-US")
    $wfTemplate=$web.WorkflowTemplates.GetTemplateByName("Three-State",$culture)
    $associationWF=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($wfTemplate, "myThreeStateWF",$taskList,$historyList)
    $ct.WorkflowAssociations.Add($associationWF)
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
    Here is a demo about how to update it using C#
    http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-associate-workflow-to-content-type-in-a-feature
    Wayne Fan
    TechNet Community Support

  • External Content Type Using SQL

    I’m trying to setup an external content type using just SharePoint designer. 
    I will need to be able to show other individual within the organization how to create these content types so getting it to work with just SharePoint designer is the goal. 
    No Programming involved please.
    Abbreviated Steps I have taken
    The account that we will use to connect to 2012 SQL server has been created and the correct permissions have been granted to the database.
    The secure store service account has been created and setup
    Go into SharePoint designer 2010 to create the external content type using
    Impersonated Custom Identity and inputting in the username and password that was setup in SQL server and added to the secure store credentials for the secure store service. I receive error cannot login with the provided credentials.
    I have searched the web trying to correct this issue and cannot find anything that will assist. 
    Everything either shows you to connect with windows identity (not an option) or breezes past this issue.

    To connect as an impersonated custom identity you have to:
    1. Be sure SQL login on SQL Server uses SQL authentication
    (not Windows one!)
    2. Create target application in Secure Store with:
      a. Target app type - "Group"
      b. Field types - Username and
    Password
    3. Don't forget to grant required permission to a new Traget Application.
    Here is a good guide (look at steps 4-8):
    http://lightningtools.com/bcs_meta_man/sharepoint-2010-secure-store-service-and-oracle/

  • Hide content type from the new menu but show in edit form

    SharePoint Online, I have following 4 site content types Word Document Excel document PowerPoint document General document
    These content types are being used in a document library and "Word Document" is the default content type, When user clicks on "new" menu, all 4 content types are shown.
    I don't want to show "General document" in the new menu but I want to show in edit form, I have marked it hidden in the library settings but now it is not visible in the edit form.
    Any idea how can I hide content type from the new button but show in edit form?

    Hi,
    Whether you use SharePoint online 2013.
    If we hide the content type in the library settings, the content type will not be displayed in both new menu and edit form.
    To accomplish your qequirement, we need to use css code:
    style <style type="text/css">
    ul.ms-cui-menusection-items32 li:nth-child(4) {
    display: none !important;
    </style>
    perhaps your environment is different with mine, you need to make a little change to the code. 
    Best Regards,
    Lisa Chen
    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]
    Lisa Chen
    TechNet Community Support

  • How to retrieve the content type used in a document library (C# - Client Model).

    Hello,
    I need to know if it's possible to retrieve the content type used in a document library, so I can know the columns active and used in this document library. I am using the Client Model in C#.
    Thanks

    First, retrieve your document library as a List object. Then, use the
    List.ContentTypes property to iterate through all the content types assigned to the list.
    Blog:
    blog.beckybertram.com |
    RSS | @beckybertram |
    SharePoint 2010: Six-in-One

  • Creating app scoped external content type using Provider Hosted App in sharepoint 2013 using visual studio 2012

    Hi,
    I am creating provider hosted app in visual studio 2012 using app scoped external content type having OData with Northwind url
    App manifest start page url  :
    ODataNewAppWeb/Pages/Default.aspx
    In XML it is:
    <StartPage>~remoteAppUrl/Pages/Default.aspx</StartPage>
    When i am deploying app pressing F5 the app gets deployed successfully....
    Now i am changing my start page url in Appmanifest like this:
    ODataNewApp/Lists/Employees
    In XML it looks like:
    StartPage>~appWebUrl/Lists/Employees</StartPage>
    When i am deploying app pressing F5 the app..
    Getting register SOD error.....
    I have followed all the steps like:
    1)Creating app domain
    2)Starting all the required services
    3)Creating root site collection
    But still no success.. Please help me on this.... I am struggling with this from two weeks...

    Have you set up a wildcard DNS entry for the spapps.com domain?
    Also if you're trying to connect from the server you might be hitting loop back check issues.

  • List field vs. Content Type Field - Powershell

    Hello,
    We have a bunch of document libraries where we have a List Column that contains information.  We have recently added a content type to the libraries and would like to copy the information from the List Column to a field in the content type.
    How do I use powershell to refer to these fields?
    If I have the Document Library (List) as a variable $list then I assume that I refer to the field as $list.$column.  But how do I do the same for the document?   How do I iterate through each document in the library to accomplish the same thing
    with a for loop?
    Something like:
    $list = $web.GetList("My List Name")
    foreach ($document in $list)
    $document.Fields["Document Field"] = $list.Fields["List Field"]
    $document.update()
    Any help would be greatly appreciated,
    Matt

    your code should be similar to
    $web=Get-SPWeb http://your_site_url_here
    $list=$web.Lists["List_Name_here"]
    foreach($item in $list.Items)
    #your logic here
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • Error while creating an external content type using wcf service.

    Hi!
      I have been asked to create a wcf service to expose sql data and populate them in a list using external content type.i have created the service but while creating the content type it gives me error. Can anyone suggest me about which url should
    be used in service metadata url and service endpoint url.
    Thanks in advance.

    You can refer these links, may be helpful
    https://msdn.microsoft.com/en-us/library/office/jj163810.aspx
    https://msdn.microsoft.com/en-us/library/office/gg318615(v=office.14).aspx
    http://www.dotnetcurry.com/showarticle.aspx?ID=799
    http://www.c-sharpcorner.com/UploadFile/Roji.Joy/connecting-to-a-web-service-using-business-connectivity-serv/
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • External content type using wcf service

    Hi,
           I have been asked to create a wcf service to expose sql data and populate them in a list using external content type.i have created the service but while creating the content type it gives me error.
    "The server was unavle to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetails (either from ServiceBehaviorAttribute or from the <serverDebug> configuration behavior) on
    th server in order................................"
    Can anyone suggest some help.
    Thanks..

    Hi,
    Based on your description, you encountered the error when you create the content type.
    You can turn on IncludeExceptionDetails or use Service Trace Viewer Tool to see the details about the error.
    There is a similar case:
    http://stackoverflow.com/questions/14217700/the-server-was-unable-to-process-the-request-due-to-an-internal-error-in-wcf-er
    The article below is about how to use the Service Trace Viewer Tool to help you analyze diagnostic traces that are generated by WCF.
    https://msdn.microsoft.com/en-us/library/ms732023.aspx
    The articles below are about how to turn on IncludeExceptionDetails
    http://stackoverflow.com/questions/8315633/turn-on-includeexceptiondetailinfaults-either-from-servicebehaviorattribute-or
    http://stackoverflow.com/questions/2483178/set-includeexceptiondetailinfaults-to-true-in-code-for-wcf
    The article is about how to build WCF Web Services for SharePoint 2010 Business Connectivity Services
    https://msdn.microsoft.com/en-us/library/office/gg318615(v=office.14).aspx
    Best regards
    Sara Fan
    TechNet Community Support

  • "Invalid Content Type" using oracle.example.hr empsecformat in EA2 listener

    We've done a new vanilla install of Apex 4.1.1.00.23 and applied the patch that comes with the EA2 listener
    We then created a workspace and logged in, looking at the Restful services we can see the oracle.example.hr in there.
    Using the empsecformat/JONES
    we just get an error of :
    400 - Bad Request
    Invalid Content Type
    We get this if we use the test button on the page also.
    Has anyone got this working out of the box?
    The listener stdout isn't showing any errors what so ever

    Does not only happen when using JAX-WS.
    the following servlet code is enough to reproduce the problem :
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/xml;charset=\"utf-8\"");
    It only occurs on 10.1.3.4.0 (works fine on 10.1.3.3.0 and 11.1.1.1.0 TP4)
    Regards

  • Protocols or COntent type used by the iPod Maps app

    I use the Map app on my iPod Touch (2G) all the time. Today I am on vacation and in spite of the fact that I have good WiFi connectivity, two apps will not function at all: The NY Times reader and the Apple Maps app. While you can use Safari to bring up the NY Times website (http://www.nytimes.com) and Google maps (http://maps.google.com), you cannot bring up http://mobile.nytimes.com in Safari.
    I believe the local WatchGuard Firewall at this resort is filtering out certain types of content it believes may be somehow destructive. I can see the error message: Unsafe content type "application/xhtml+xml" reported when attempting to access mobile.nytimes.com
    As far as the Maps app goes, one cannot bring up any bookmark nor determine one's current location, viz., "Your location cannot be determined." after some delay. I understand that in certain circumstances the message simply implies that the WiFi access point in use may never have been mapped, but the inability to look up any known good arbitrary address implies to me a communications problem.
    Anyone know what protocol and/or content type may be is use by the Maps app?

    If you want to create a message that has both plain text and html versions of the main
    message content, you want to create a multipart/alternative message, as described in
    this FAQ entry.
    If that message also needs to have attachments, you should embed the multipart/alternative
    part in a multipart/mixed message, along with the attachment parts.
    If the html part needs to reference images included with the message, you would replace
    the text/html part with a multipart/related part, as described in this FAQ entry.
    Combining all these techniques together can seem a bit complicated unless you understand
    recursion! :-) Remember that in addition to creating a body part with a text content type,
    you can create a body part with a multipart content type, and use that body part in the same
    places you would use a text body part.
    As for making sure your message isn't marked as spam, well, you're probably asking in the
    wrong place, but the simple answer is to make sure that it's actually not spam! Usually the
    structure of the message isn't as important as the content of the message.

  • Changing Content Database using Powershell

    Hi,
    I have a web application created. I have a another content DB, which I want to associate to the existing web application.
    I mean, the existing content db should be removed and the new Content db attached.
    What are the steps to achieve the same using powershell?
    Thanks

    Hi,
    For your issue, you can
    Dismount-SPContentDatabase and Mount-SPContentDatabase.
    A typical command to detach a database would be:
    Dismount-SPContentDatabase -Identity <contentdb>
    A typical command to attach a content database would be:
    Mount-SPContentDatabase -Name <contentdb> -DatabaseServer <dbserver> -WebApplication <webappname>
    Here is a link about
    Managing SharePoint Content Databases with PowerShell, you can use as a reference:
    http://www.mssqltips.com/sqlservertip/2608/managing-sharepoint-content-databases-with-powershell/
    Best Regards,
    Lisa Chen
    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]

  • Add Already Existing Taxonomy Column to Content Type using visual Studio

    Hi
    I need to add existing Taxonomy Site Column to my Content type, which will be used in  my SharePoint list Everywhere I have seen it is talking about how to create managed metadata column and then add it to your site content type.My column is already
    present just I need to use it. How can I do this?
    <ContentType
    ID="0x0100b58d33764b384da58bbadee9721e1843"
    Name="MyCustomContentType"
    Group="Custom"
    Description="Custom provisioned contenttype containing a Taxonomyfield"
    Inherits="TRUE"
    Version="0">
    <FieldRefs>
    <FieldRef ID="8D0458C1-0FB7-4981-BEE1-52D0DF01895C" Name="MyTaxonomyField"/>
    <FieldRef ID="3a913424-fc7f-49ef-8fb6-a2ca1712cdc3" Name="MyTaxonomyFieldTaxHTField0"/>
    <FieldRef ID="f3b0adf9-c1a2-4b02-920d-943fba4b3611" Name="TaxCatchAll"/>
    <FieldRef ID="8f6b6dd8-9357-4019-8172-966fcd502ed2" Name="TaxCatchAllLabel"/>
    </FieldRefs>
    </ContentType>
    Where I can get ID of existing Site Columns as well as TaxCatchAll and TaxCatchAlllabel

    Hi,
    To get the ID of existing site columns, you can use SharePoint Manager 2010:
    Take a look at the post:
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/f95fb1e9-d9a9-48e8-b99e-4262bffa8968/sharepoint-manager-2010-how-to-update-list-schema-xml
    Best Regards,
    Lisa Chen
    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]

  • BCS External Content Type using Stored Procedure with parameter

    I have a requirement wherein I will be using External Content Type (BCS) using a Stored Procedure.
    The stored procedure has parameters.
    I have set up Read List and Read Item
    However, when I visited my list, I cannot enter any parameter.
    Can you show me a guide on how to configure this with parameters?
    Thanks!
    ----------------------- Sharepoint Newbie

    Hi,
    Here are the references for creating an External Content Type to support Read List and Read Item operations:
    http://troyscott.ca/2010/07/02/creating-an-external-content-type-in-sharepoint-2010/
    https://msdn.microsoft.com/en-us/library/office/ff728816(v=office.14).aspx
    Regards,
    Rebecca Tu
    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]

  • Error while Connecting to external content types using sharepoint designer 2013

    I have a standalone development sharepoint server 2013.
    After i installed BDC service, i try to create a external content list.
    When i try to open the site in sharepoint designer i am getting the error like
    "Could not establish Trust relationship for SSL/TLS secure channel with authority "sitename"
    the underlying connection was closed:could not establish trust for SSL/TLS secure channel"
    I tried creating Certificate in IIS8 adn added the certificate in manage trust in sharePoint central admin too and i have restrated IIS too.
    But the issue is not resolved still.
    PLease help me this.

    May be you need to install certificate on server. Try below:
    http://www.brainlitter.com/2012/03/13/sharepoint-2010-and-cert-trust-could-not-establish-trust-relationship-for-the-ssltls-secure-channel/
    To local system
    http://www.c-sharpcorner.com/uploadfile/anavijai/could-not-establish-trust-relationship-for-the-ssltls-secure-channel/
    If this helped you resolve your issue, please mark it Answered

Maybe you are looking for

  • How to create Standard text for terms and conditions of po print form

    Hi anybody,   I want create Terms and condtions inside smartforms PO FORM , how do i create terms and conditons and how use font size? I don't want hard code inside smartforms , I will create seperate texts for terms and condition after i include ins

  • Using javascript to control the browser

    Hi all, One of the most requested features on our first Breeze project was a "quit" button. The easiest way to do so in an HTML environment is to use the command javascript: window.close(); Type this into the address bar on your browser, and hit retu

  • Can't start IntegratedWeblogicServer in JDeveloper

    Hello all, Installed v11.1.2.3.0 of jDeveloper on Win 7 machine. Everything installed normally, but when I start IntegratedWeblogicServer the following error comes up: Starting WLS with line: D:\Oracle\MIDDLE~1\JDK160~1\bin\java -client -Xms256m -Xmx

  • Multilinual indexing and searching!

    Hi, I've installed a Multi_Lexer for German, Swedish, French and English, how it is described in the interMedia documentation. Creating an index works and searching works, too. But I still have a problem. Is there a way to combine ALTERNATE_SPELLING

  • PDF files aren't working

    As I place PDF files on this site, MANY are not loading when clicked on. Could it be the name of the PDF, like: Grason Stadler.pdf VS Grason_Stadler.pdf? It's puzzling to me. Any help would be WELCOME! Thanks Link: http://audiomed.com/Audiomed.com/Cl