Using list items to create sites programatically

Hello All,
I am looking to programatically create sites based on items in a SharePoint list. The list has 4 columns, Name, Email, ManagerName, ManagerEmail.
The aim is to use PowerShell to create a foreach loop, that creates a site (using the "Name" column as the site title/URL) based on the #STS01 teamsite template, breaks permission inheritance, and then gives the Manager ("ManagerName")
contribute access to the site.
Not sure where to start with this, any advice would be appreciated!
Cheers!

Hi,
Here is the complete PowerShell code to create site with unique permissions and assign manager with contribute permissions.
I have created a list with following columns as shown in the screenshot.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$sourceWebURL = "http://sp2013"
$sourceListName = "MySites"
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
$spSourceItems = $spSourceList.GetItems()
foreach($item in $spSourceItems)
$siteTitle = $item["Title"]
$siteName = $siteTitle -replace " ", ""
$NewSiteUrl = $sourceWebURL+"/"+$siteName
write-host "Title:"$siteTitle
write-host "Url:"$NewSiteUrl
#Create User Object from the List Item
$userWithContribute = New-Object Microsoft.SharePoint.SPFieldUserValue($spSourceWeb,$item["ManagerName"].ToString());
#Create Sub-site with Unique Permissions
$newWeb = New-SPWeb -Url $NewSiteUrl -Name $siteTitle -Template "STS#0" -UniquePermissions
#Assign Manager with Contribute permission
Set-SPUser -Identity $itemUser.User -Web $newWeb -AddPermissionLevel "Contribute"
https://gallery.technet.microsoft.com/PowerShell-Script-to-d888fcdd
Please don't forget to mark it answered, if your problem resolved or helpful.

Similar Messages

  • How to create a tree structure using list items(tlist)

    HI every one,
    As we know how to create a tree structure using Hierarchy item type.
    We have a requirement to create The same tree like structure using List Item(Tlist)
    I would be so appreciated If you send with an example
    Thanks
    RangaReddy

    Hi all
    Any one help me please
    Actually our client requirement is creation of tree structure using list item,similar to what we used in oracle Application(FNDSCSGN) form.We did the tree structure using hierarchy tree using Htree and Ftree.It working excelently.For client requirement, we want to use list item.How PJC(Pluggable Java Components) is useful for using list item(Tlist).I can't understand how it is useful.
    Do you have any example please help me.
    Thanks
    RangaReddy

  • Create list item in parent site when list item is created in child site?

    SharePoint online - Can I create a list item in a parent site when a new list item is created in child site? Possible with workflows?

    Hi Shafaqat,
    From your description, my understanding is that you want to create a list item in the parent site when a new item is created in the subsite via workflow.
    Per my knowledge, there is no OOTB workflow action to achieve your requirement. I suggest you develop your own workflow activity to do it, or you can try to find a third party workflow solution to do it.
    Here is an article about how to create a custom workflow activity, you can take a look at:
    http://www.sharepoint-reference.com/Blog/Lists/Posts/Post.aspx?ID=37
    Best Regards,
    Wendy
    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]

  • Switching b.w reports using list item - missing data on initialization

    Hi,
    I have two interactive reports (one with product view and second with Line of business view)... I've allowed my users to switch b.w prod/LOB views (using list item).. I am using LOB view as a default view
    My problem is that when the user logs into the application LOB view report appears by default (as desired) but contains no data (displays message: No data found) until I switch it to product view (via list item) and then switch back to LOB view...Not sure what's causing it
    I've stored sample on APEX.ORACLE.COM for your review and comments
    Here are the credentials:
    Please note that the form is on page 2
    Thanks in advance
    Edited by: qwe12654 on Apr 21, 2011 3:26 PM

    Hi,
    I changed the Computations to "Value of Item in Expression 1 is NULL" and put the item name into Expression 1.
    You had a PL/SQL expression of:
    NVL(:P2_YEAR,'NULL') = 'NULL'
    I think you could have used:
    :P2_YEAR IS NULL
    or
    NVL(:P2_YEAR,'0000') = '0000'
    I'm not 100% sure what effect there would be of using 'NULL' within a statement - it should just be seen as a string, but, as you can see from the results, something wasn't working as we'd expect.
    Apart from changing the way that the default value is computed for the Year, that was the only change that I made.
    Andy

  • Search for list items by Created Date using caml

    Hi all,
    I'm trying to find list items with specific attributes using caml.
    I created a caml query that uses Last_x0020_Modified and File_x0020_Size for searching items.
    then i tried adding Created and Created_x0020_Date both either as Lookup or as DateTime to the caml.
    But since i added Created/Created_x0020_Date my query fails with 500 Internal Server Error.
    Can someone tell me what I'm doing wrong?
    here is my complete Entity I'm sending to SharePoint 2013:
    {'query' : { '__metadata': { 'type': 'SP.CamlQuery' }, 'ViewXml': '<View Scope="Recursive">
    <Query>
    <Where>
    <And>
    <Leq>
    <FieldRef Name="Last_x0020_Modified" />
    <Value Type="Lookup">2015-02-25T10:10:03</Value>
    </Leq>
    <Geq>
    <FieldRef Name="File_x0020_Size" />
    <Value Type="Lookup">1</Value>
    </Geq>
    <Leq>
    <FieldRef Name="Created" />
    <Value Type="DateTime">2015-02-25T10:10:03</Value>
    </Leq>
    <Eq>
    <FieldRef Name="FileDirRef" />
    <Value Type="Text">/sites/DennisDevSite/alib/Ordner1</Value>
    </Eq>
    </And>
    </Where>
    </Query>
    </View>' } }
    Thx in advance
    Dennis

    Try appending "Z" to DateTime. Change 
    <Value Type="DateTime">2015-02-25T10:10:03</Value>to <Value Type="DateTime">2015-02-25T10:10:03Z</Value>
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • Using list item with set_item_property

    I have a list item named say LIST_A. I have a text field say TEXT_A. Is it possible at run time to make the list item available as list of values for TEXT_A using set_item_property or something else?
    Any help is appreciated. Thanks.

    You can create a record group from the elements in the list item and assign it to an LOV at runtime.
    Check out the create_group, get_list_* and set_lov_property entries in the help system.

  • Need help using list item as to filter hire_date

    hi to all, how can i use the list item as to filter hire_date based on the elements inside the list item
    it goes something like this
    HIRE_DATE----------------LIST_ITEM=JAN
    01-JAN-10
    02-JAN-10
    03-JAN-10
    HIRE_DATE----------------LIST_ITEM=FEB
    01-FEB-10
    02-FEB-10
    03-FEB-10
    the sorting will do after i press the button
    thanks in advance :)

    sir i tried the code and it says: FRM-41003: This function cannot be performed here.
    what im really want to do is that after retrieving the dates from a push button, (remember yesterday where you help me retrieving multiple data).... i have a list_item where it has the elements JAN,FEB,MAR,APR,MAY.
    and then after selecting different month from the list_item the values that ive retrieve will be filter according to the value in the list_item
    it looks something like this:
    stud_id = 1001
    time_in
    01-JAN-10
    02-JAN-10
    03-JAN-10
    01-FEB-10
    02-FEB-10
    03-FEB-10
    after selecting FEB from the list_item it will goes like this
    time_in
    01-FEB-10
    02-FEB-10
    03-FEB-10
    thanks..
    -charles

  • Need help using list item as filter[WRONG POST PLS IGNORE]

    SORRY WRONG POST...
    Edited by: cjtjaime on Oct 8, 2010 12:33 AM

    sir i tried the code and it says: FRM-41003: This function cannot be performed here.
    what im really want to do is that after retrieving the dates from a push button, (remember yesterday where you help me retrieving multiple data).... i have a list_item where it has the elements JAN,FEB,MAR,APR,MAY.
    and then after selecting different month from the list_item the values that ive retrieve will be filter according to the value in the list_item
    it looks something like this:
    stud_id = 1001
    time_in
    01-JAN-10
    02-JAN-10
    03-JAN-10
    01-FEB-10
    02-FEB-10
    03-FEB-10
    after selecting FEB from the list_item it will goes like this
    time_in
    01-FEB-10
    02-FEB-10
    03-FEB-10
    thanks..
    -charles

  • Need solution for sub site when we click on the list item of a list? by using out of out of box feature in share point 2010

    Hi  all ,I have Task that When click on list item a new sit will open fo 
    for ex:   I created a List (test list)  and list items are Project name,Application, Start date ....,when i click on Project name a new sub site will open,
    Is there any out of box feature ?
    for that Please help any body knows
    Thanking You, 

    This is a forum related to System Center Service Manager. Your question seems to be related to Sharepoint 2010. Maybe it's better to ask in the Sharepoint 2010 forum, for instance: General
    Discussions and Questions
    Andreas Baumgarten | H&D International Group

  • Execute Query by using LOV (List Item)

    Hello Everyone,
    I did research on how to use List Item with Query but i am still confused since i am a new to the FORM.
    I have created a form where user enters
    Start Date: -- this field user can just type the date
    End Date: -- this field user can just type the date
    Violence: -- this is my List Item (Drop down Menu) where user select the code
    once they select the parameter i have created "Execute" button and it will give number of violence within the date range. the query is giving me right number or violence but then i need to drill down to details.
    so i created a trigger when user double click on the number ( result number) it will pop up another window and display the details
    For example:f_name, l_name, ssn etc...
    Now, my problem is when i double click on (Text Item) it. Its not giving me the number of records that i have get when i execute at the first by using date range and violance code.
    This is the step that i have use:
    when user click Execute button the PL/SQL code:
    Query_step1(:start_date,:end_date,:violations);
    when user double click on Text Item once they have the number this is what i have used code for PL/SQL
    begin
         go_block('xxhc_hearings_rpt_v');
         set_block_property('xxhc_hearings_rpt_v',default_where,'hearing_result = '||'''TERMINATE'''||'and violation '||''||:violations||''||'and propose_term_dt between '||''''||:start_date||''''||' and '||''''||:end_date||'''');
         execute_query;
    end;
    So please anyone can give me little direction that will be a great help.
    Thank You.
    Keyun

    Use the system variable LAST_QUERY to check that you SQL is valid. Assign it to a temp field in the block and check it out.

  • Using Create Item to create a Link to a Document

    I want to use the Link to a Document content type and create it with a workflow. I can't seem to get it to work. I'm not putting in the right parameters for sure.
    Content Type ID: Link to a Document
    Path and Name: test
    URL: http://test
    I'm no sure what else to put.  I've tried Title.  I've tried the URL has
    http://test , Test.  Not sure what to do.
    David Jenkins

    Hi,
    It is a known issue that In our SharePoint 2013 farm, we are running into the issue with Workflows where any workflow with "Create List Item" which create a link to a document item in a Document Library.
    It is by design.
    Here are similar issue post, you can take a look at:
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/64c717c5-5108-411e-aa7a-b20d3afa584c/workflow-cannot-create-a-link-to-a-document-item-in-document-library?forum=sharepointcustomization
    https://social.technet.microsoft.com/Forums/en-US/e2dd1d1e-d7d9-41b5-b9f2-e73138553994/problem-while-starting-on-a-workflow
    Besides, you can creating a 'Link to a Document' item in a SharePoint document library programmatically:
    https://erroreimprevisto.wordpress.com/2014/05/10/sharepoint-2013-programmatically-add-link-to-a-document-file-in-a-document-library/
    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]

  • Syncronize excel to Sharepoint list (i.e. a site calendar)

    Hi
    I need some help relating to syncing an excel sheet saved on sharepoint to a calendar on the same sharepoint site.
    What I have is as follows:
    1. A project site with an excel sheet save in a document app.
    2. A Calendar on the project site.
    That excel sheet has numerous formulas where there are two output columns, one with a date (i.e. date output) and one with a document name (Document output).
    What i would like to happen is as follows: When the "date output" cell (which is normally blank) populates with a date i would like the accompanying "document output" cell to populate into the "date output" date on the site's
    calendar.  I have read a number of comments on syncing lists back to excel but none seem to pop out as answering my query. I have no idea if this is possible.
    Any help would be appreciated.
    Ray

    Hi,
    Let’s verify that whether the two output columns are document library columns or in the excel sheet table. 
    If they are document library columns, you can create a workflow with SharePoint Designer using 2010 platform, choose create the list item action, create
    list items into a calendar list.  Configure the document
    library columns to match the columns in the calendar.
    Here is a link about how to use Create List Item Action, you can use as a reference:
    http://blogs.salmanghani.info/create-item-workflow-sharepoint-designer-2010/
    If you have any question about this issue, 
    please feel free to reply me.
    Best Regards,
    Lisa Chen

  • No list elements defined for list item.

    hi master
    when i use list item and run then give this error
    FRM-30351: No list elements defined for list item.
    List PRODUCT_NO
    Created form file MODULE1.fmx

    Try posting your question to Forms

  • List Item "Shared With" dialog error

    Just recently I started getting an error whenever I use the "Shared With" button on a list item to set permissions for the item. The dialog comes up, but the loading symbol continues to run and the Invite People, Email Everyone and Advanced options
    are not displayed. I ran a debugger while loading the dialog and came up with this error:
    Error: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly
    requested.
    The error occurs in the sp.js file. The java script was never altered and there was no list or site changes. This occurs on all list items within the site farm. The only things I can think of that were changed is Windows was updated on the server running
    SharePoint. Has anyone seen problems like this before?

    There should be two possible ways to fix this:
    As mentioned by Kelly above, it looks like the issue was introduced by update KB2899508 - uninstalling
    that update should get you going again (haven't tried that one myself).
    Fix the broken file(s)
    the problem is in sharing.js (production version) and sharing.debug.js (debug version). Both files can be found at \Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
    production: 
    change 
    k.load(g,"ID","FileRef","FileLeafRef","Client_Title")
    to:
    k.load(g,"ID","FileRef","FileLeafRef","Client_Title","Title")
    debug:
    change
    cctx.load(listItem, 'ID', 'FileRef', 'FileLeafRef', 'Client_Title');
    to
    cctx.load(listItem, 'ID', 'FileRef', 'FileLeafRef', 'Client_Title', 'Title');
    I've made my changed files available for download; I recommend you only use these as reference and not actually use files downloaded from some random web site on a production system.
    http://www.bene.priv.at/sharepoint/sharing.debug.js
    http://www.bene.priv.at/sharepoint/sharing.js
    Hope this helps.

  • List Item problem in oracle forms

    Hi,
    I am using list item in oracle forms 6i and facing one problem. I am populating list using following built-in.
    Clear_list()
    Create_Group_From_Query( )
    Populate_list()
    The problem I am facing is when list gets populate it keep the cursor at last element of list with null value. I want cursor to go at first item in the list. Is this thing is possible. The list item I am using is pop-list. In combo its showing list perfectly but I have to use pop-list only. Please help to come out of this problem.
    Thanks in advance
    Shweta.

    Hi Shweta,
    Please post your query in Oracle Forms discussion forum.
    Thanks,
    Wilson.

Maybe you are looking for