Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Last active June 2, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kilasuit/cec0f65f852ba9b9c4fb12d66a143a65 to your computer and use it in GitHub Desktop.
Save kilasuit/cec0f65f852ba9b9c4fb12d66a143a65 to your computer and use it in GitHub Desktop.
Initialize-SPPS -siteURL https://tenant.sharepoint.com/ -UserCredential $MYO365cred -IsOnline 1 -Verbose
Get-List "TestList" # Creates list variable
Get-ListFields -ListTitle $list.Title # Creates listfields variable
Get-Listviews -ListTitle $list.Title # Creates listviewIDs variable
$fieldstocopy = $listfields | Where-Object { $_.FromBaseType -notlike "True" }
$viewstocopy = New-Object System.Collections.Arraylist
$ListViewIDs | foreach { Get-Listview -ListTitle $list.Title -ListViewName $_.Title ; $viewstocopy.Add($ListView) }
Initialize-SPPS -siteURL https://tenant.sharepoint.com/sites/testsite -UserCredential $MYO365cred -IsOnline 1 -Verbose
Add-List -listTitle 'TestCopy' -templateType GenericList -Description ESTest -Verbose
Get-List "TestCopy"
foreach ($fieldtocopy in $fieldstocopy)
{
Add-Field -listTitle $list.Title -fieldName $fieldtocopy.Title -fieldXML $fieldtocopy.SchemaXML
}
foreach ($viewtocopy in $viewstocopy)
{
New-ListView -ListTitle $list.Title -ViewTitle $viewtocopy.Title -ViewRowLimit $viewtocopy.RowLimit -ViewQuery $viewtocopy.ViewQuery -ViewFields $viewtocopy.ViewFields
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment