Using SPmanagementshell to create library ,version enable & Add content type

Hi Folks,
 How to create library document,enable version, add content type in every site using SPmanagementshell.
Now i am doing user interface,it is  taking more time to do this task.
Please give solution using SPmanagementshell to do this task.
I would be great if someone help.

Hi,
Please try code given below:
$spWeb = Get-SPWeb -Identity http://SPServer
$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary
$spWeb.Lists.Add("My Documents","My Doc Library",$listTemplate)
$spDocumentLibrary = $spWeb.GetList("My Documents")
$spDocumentLibrary.EnableVersioning = $true
$spDocumentLibrary.ContentTypesEnabled = $true
$spDocumentLibrary.Update()
#Add site content types to the list
$ctToAdd = $site.RootWeb.ContentTypes["<NAME OF ContentType>"]
$ct = $spDocumentLibrary.ContentTypes.Add($ctToAdd)
$spDocumentLibrary.Update()
Hope it helps!
Thanks,
Avni Bhatt
If this helped you resolve your issue, please mark it Answered

Similar Messages

  • Using a newly created Library document to create a list item and attach itself

    I have a workflow that moves a document from one library to another.
    When a document is moved to a certain library I want to create a list item with a link to the document in the list item.  Keep in mind there could be 10 files submitted to the library, so then in my list I would want 10 new list items created for
    each file, with a link to the individual file. or is there a way to attach the document to a newly created list item programmatically?
    is this possible?

    Hi,
    According to your post, my understanding is that you wanted to use a newly created Library document to create a list item and attach itself.
    I recommend to create a workflow assocaited to the second library, and start the workflow automatically when an item is created.
    Then add action as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How use jndi to create a organization and add a  user  to it.(ÈçºÎ´´½¨Ò»¸ö×éÖ¯µ¥Î»)

    how use jndi to create a organization and add a user to it¡£THANKS£¡
    ÈçºÎ´´½¨Ò»¸ö×éÖ¯µ¥Î»,²¢½«Ò»¸öÓû§Ìí¼Ó½øËü¡£Ð»Ð»£¡

    Hi,
    The command above about creating a group only works for the root site of the site collection, because the scope of the user group is site collection level, these groups
    can be used in all the sites in this site collection.
    With the existing groups in the root site, we can add users into them and grant specific permissions of a specific sub site to these groups.
    Here is a demo about how to assign permission to a group using Client Object Model(though in C#) for your reference:
    http://www.c-sharpcorner.com/UploadFile/54db21/set-permission-to-group-in-sharepoint-2010-programmatically/
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Add content type to Team Discussion List

    Hi
    I was create a content type with some culoms. then I was add content type on the Team Discussion List and was set as a default item.
    i was add item and filled it and saved
    but there aren't any view! perhaps there don't save!! Where  this item are saved?  

    Hello,
    How did you create that content type? By default all the post gets saved in message content type and display in subject view. Have you tried to open each view ? if not then do so.
    I have also found one similar thread for you info:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/7b074ba1-aed0-49af-8685-0e206001f5d0/custom-discussion-content-type-in-sharepoint-2010?forum=sharepointgeneralprevious
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Search/Filter a Picture Library with an External Content Type

    We have the need to manage 50,000-100,000 images of ODOT Bridges. Currently, they are added to a SharePoint 2010 Picture Library that is associated to an External
    Content Type. To handle list threshold and performance issues, we are using folders. There are 2-10 images per folder. SharePoint works great for administering (Adding, Updating, Deleting).
    The problem that we have is providing an interface that anonymous users can search/filter. Prior to adding the external content data, we stored the metadata in the
    picture library itself. We had an InfoPath form that had multiple (3-5) filtered dropdowns which passed a filter to the picture library web part.that worked without issue.
    Do you know of an easy way to search/fliter for one picture library via dropdowns when all of the metadata is stored in a external content type?
    Any direction would be greatly appreciated.

    Hi James,
    How about create a page in SharePoint Designer instead of using InfoPath form? If you would like to have a try, please follow this step:
    1. Create a data source using database connection type. Get data from the same data from the data source you used to create the external content type.
    2. Add a page > Click Insert tab in the ribbon of Designer > Click Data Source > And insert the data source you created in step1.
    3. Insert > ASP.NET > Drop Down list > Choose Data Source for the drop down list control > Select the data source you add in step 2. And Enable AutoPostBack for the drop down list control.
    4. Insert the picture XSLT list view web part > click Parameters on the ribbon > Create a new parameter > Select Control as parameter source > Select the drop down list control you added in step 3.
    5. Create a filter for the XSLT list view web part > add the fitler equal to the parmaeter you added in step4.
    Best regards,
    Emir

  • Versioning and Video Content type does not work.

    Hello,
    I have out of the box sharepoint installed.
    When I apply versioning to a library. And try to see "Document set version history" (as I suggest Video content type actually inherits from Document Set). I don't see any version.
    Can you tell me how can i see versions of the "Video" content type item in this Version History window?

    Document set versions are slightly different than item versions. Document sets can be managed by a separate ribbon tab called Document Set and group called Manage.
    Check below link for detail go through:
    How to retrieve document set version history
    Manage versions for Document Set
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer :)

  • How to use custom aspx page as template for custom content type

    Hi,
    I have created custom content type and custom aspx page. I want to use aspx page as template for custom content type.
    Can anybody please let me know how to accomplish this?
    Any help would be appreciated.
    Thank you,
    AA.

    Check if you are looking for the below
    http://www.sharepointpals.com/post/How-to-Create-a-Page-Layout-(PageLayout)-with-ContentType-in-SharePoint-2013
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How do I add content types in the Applications section under Preferences

    I have several applications I use regularly on multiple macs. For specific file types, Firefox 4 will only give me the option to save the file. It does not allow me to select an app to use, and, the file type is not listed in the Content Type list on the Applications tab in Preferences.
    In particular, I have XLS associated with Excel, but XLSX is not listed, so all I can ever do is save it, then open it.
    Another case, on one mac, PDF is associated with Preview, but it is not listed on the other, so again, all I can do is save it. It doesn't allow me the option to change actions.
    There must be a place to change the default behavior for unknown file types, isn't there?

    You can look at this extension:
    *MIME Edit: http://space.geocities.yahoo.co.jp/gl/alice0775/view/20080912/1221150790
    * User Info for White Alice0775: https://addons.mozilla.org/en-US/firefox/user/84420/

  • Unable to add Content-Type=multipart/related; type="text/xml";

    hi all
    am trying to add the following to my soap message that include attachment
    but its not working
    Content-Type=multipart/related; type="text/xml";
    boundary="----=_Part_0_14732323.1039686671216";
    Content-Length=4259;
    can any body help plzzzzzzzz

    Hello again,
    My solution works and does not work. Content type is ok, but strange characters appear to the end of the attachment data.
    Like this
    ...</E1EDS01></IDOC></ORDERS01>H úãž6×½ ã½5Õ×¼ÛgžÛNÝ}þ[ëMu201E
    Where did these come from? I tested in a way that I changed the ContentType back to application/xml and attachment is fine again.
    Regards,
    Pekka

  • Create Process Chains and add Process Types using ABAP

    Does anyone in here have experience in creating or changing a full Process Chain including the Process Types?
    The reason is, that we have a lot of source systems with "similar" loads.
    We already have an ABAP that can copy the chain and replace the InfoPackages. But we can't find a way to create/change a process, e.g. 'Hierarchy Save', 'PSA Delete' etc.
    Any ABAP samples is highly appreciated!
    Best Regards Jakob

    Hello Jakob
    did you find already this how to paper: "How to ... Implement custom process types" ?(https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/72e0e1ed-0c01-0010-74bc-b397c8c4dadc)
    It has a code sample in the appendix.
    Hope it helps,
    regards
    Martin
    Message was edited by: Martin Lehmann

  • SCCM 2012 use PowerShell to create a GlobalCondition, limiting the Deployment Type of an Application to certain operating systems.

    Title says it all basically.
    In the GUI im able to create a Global Condition (condition type: Expression) where I can add a clause that Limits the deployment type of an application to certain operating Systems (useful for deploying 64-bit apps).
    Is there away to Trigger that Setting using PowerShell? So far I haven't found one.
    Thx in advance...

    I changed my script a little bit and can be found Here. 
    An example to use it is:
    #Get Application named "Test" from the Server "localhost"           
    $app = Get-SCCMApplication "Test" "localhost"
    #A rule will be created from the global condition rule "ForumTest" where the registry value equals to "1"
    $rule1 = Create-SCCMGlobalConditionsRule . "ForumTest" "IsEquals" 1 "Registry"
    #Add the rule to the requirement rule of the deployment type
    $app.DeploymentTypes[0].Requirements.Add($rule1)
    #And save the application
    Save-SCCMApplication $app
    PowerShell, System Center 2012, Windows 8 http://blog.lechar.nl
    Thanks Rob!
    Have unfortunately encountered some problems:
    Get-SCCMApplication does not exist. Changed it to Get-CMApplication
    Create-SCCMGlobalConditionsRule - Cant find any "Create..." cmdlets
    Save-SCCMApplication does not exist
    Get-CMApplication : A positional parameter cannot be found that accepts argument 'TestApp'.
    At H:\sctipt\SetRequirement.ps1:2 char:9
    +  $app = Get-CMApplication "TestApp" "siteServe ...
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-CMApplication], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ConfigurationManagement.Cmdlets.AppMan.Commands.GetApplicationCommand
    Create-CMGlobalConditionsRule : The term 'Create-CMGlobalConditionsRule' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At H:\script\SetRequirement.ps1:5 char:11
    +  $rule1 = Create-CMGlobalConditionsRule . "GlobalRuleName" "IsEquals" 1 "Registry"
    +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Create-CMGlobalConditionsRule:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    Cannot index into a null array.
    At H:\script\SetRequirement.ps1:8 char:2
    +  $app.DeploymentTypes[0].Requirements.Add($rule1)
    +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray
    Save-CMApplication : The term 'Save-CMApplication' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the na
    me, or if a path was included, verify that the path is correct and try again.
    At H:\script\SetRequirement.ps1:12 char:1
    + Save-CMApplication $app
    + ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Save-CMApplication:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

  • Assign default content type to any library automactially when site get created or people add the library

    we are on on premise environment, and we have a requirement that when people create a site or a sub site or even when they add a new document library , we want to ensure our custom content type is assigned as default content type to this library.
    the question is that is there any non-full trust solution, i know we probably can do it via feature stapling, or custom site template stuff. but they are NOT considered as we want PLA compliance

    Hi,
    As I understand, you would like to asscoiate a custom content type to a library when the library is created.
    With OOB option, you could try add this content type to an existing library, and save library as template. Then the library template should appear in Your Apps page, that is to say, users can directly create document library based on this template.
    As I tested, new document library created based on this template contains custom content type by default.
    With programatically methods, please refer to the similar threads below:
    https://social.technet.microsoft.com/Forums/en-US/ec9e243b-ea4c-4a46-8780-75a3a5659164/mysite-add-content-type-to-document-library-by-default?forum=sharepointadminprevious
    https://social.technet.microsoft.com/Forums/en-US/e58eb107-daa5-4a51-a139-dca2b1cf8591/set-default-content-type-for-document-libraries-on-a-custom-site-template?forum=sharepointdevelopmentprevious
    Regards,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] .
    Rebecca Tu
    TechNet Community Support

  • Create folio and add content to it using CIS 11g

    Hello,
    How should I create a folio and add content to it using CIS 11g? tried following code but it fails with error code
    Caused By: intradoc.data.DataException: !csGetFileNeedsParameter,Latest
    ISCSAdministrativeAPI adminAPI =
    application.getUCPMAPI().getActiveAPI().getAdministrativeAPI();
    Map arguments = new HashMap();
    arguments.put("NumChanges", "1");
    arguments.put("change0", "1607:addContent:1F93-3807-DFB3-4BDF-8F63");
    arguments.put("RevisionSelectionMethod", "Latest");
    arguments.put("change_data0", "dID:410");
    ISCSServerResponse serverResp =
    adminAPI.executeIDCService(context, "UPDATE_FOLIO", arguments);
    Any help is appreciated. Thanks.

    If you only use dID, you need to use: putLocal("RevisionSelectionMethod", "Specific")
    I never got this working with strictly dID. Once I fed it dDocName and then used the below it got rid of the error:
    putLocal("RevisionSelectionMethod", "Latest")
    Good luck!

  • Select option "Show this View : in Folder of Content type : {Custom Content Type Name}" while creating view using CSOM

    Hi,
    I am trying to create "View" in a Document Library and need to enable following:
    1. Mark as default View
    2. Folders -> Show this view : in Folders of Content Type : {Custom Content Type name}
    I am using following code which sets "in Folders of Content Type : " to "Folder" rather than selecting custom content type despite passing Content Type ID of custom content type.
    code:
    var itemContentTypes = clientContext.LoadQuery(web.AvailableContentTypes.Where(ct => ct.Name == viewContentType));
    clientContext.ExecuteQuery();
    var itemContentType = itemContentTypes.FirstOrDefault();
    view.ContentTypeId = itemContentType.Id;
    view.DefaultViewForContentType = true;
    view.Update();
    clientContext.ExecuteQuery();
    Please highlight what seems to be missing?
    Thanks
    Sonal

    Hi,
    Before you set the content type ID for the view, you need to add the custom content type to the library firstly.
    You can add the content type to library using OOTB feature “Add from existing site content types” in library settings or using Client Object Model.
    Here is a code snippet for your reference:
    var list = context.Web.Lists.GetByTitle(listTitle);
    list.ContentTypesEnabled = true;
    var contentType = context.Site.RootWeb.ContentTypes.GetById("0x0120");
    list.ContentTypes.AddExistingContentType(contentType);
    context.ExecuteQuery();
    More information about add exist content type using Client Object Model:<o:p></o:p>
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.contenttypecollection.addexistingcontenttype%28v=office.15%29.aspx
    Best regards,
    ZhengyuGuo
    Zhengyu Guo
    TechNet Community Support

  • SharePoint REST service to add an exsiting site content type to a list/library

    Trying to use SharePoint 2013 REST Service to add existing site content types to a list/library. Below MSDN article suggests that the POST method is available but does not say how to use it.
    http://msdn.microsoft.com/en-us/library/office/jj246793%28v=office.15%29.aspx#postsyntax_htm
    POST http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes/add(parameters)
    How do we create the body for this rest call?

    Hi You need to use the addAvailableContentType method to attach a Existing Content Type to a list/Library.
    Consider the below Sample. Take the Id of the Content Type and pass it.
    the REST API URL is 
     http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes/addAvailableContentType(contentTypeId)
    var siteUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Employees')/ContentTypes/AddAvailableContentType";
        var call = jQuery.ajax({
            url: siteUrl,
            type: "POST",
            data: JSON.stringify({            
                "contentTypeId": "0x0100E5EC1FE6D284A74A972A1776FFFE2DA0"            
            headers:
                   'accept': 'application/json;odata=verbose',
                    "content-type": "application/json;odata=verbose",
                    "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
        call.done(function (data, textStatus, jqXHR) {
            var message = jQuery("#message");
            message.text("Added Content Type Successfully");
        call.fail(function (data, errorcode, errormessage) {
            alert("Could not enable content types: " + errormessage);
    Here 0x0100E5EC1FE6D284A74A972A1776FFFE2DA0 is the Content Type Id of my existing Content type "Employees"
    Ensure the AllowContentTypes is set to True for that List/Library
    R.Mani | http://rmanimaran.wordpress.com

Maybe you are looking for