Advertisement
sharepointmatthew

Untitled

Mar 31st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. Add-Type -Path "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_15.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll"
  2. Add-Type -Path "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_15.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll"
  3.  
  4.  
  5.  
  6. $webUrl = "https://noteworthy.sharepoint.com/sites/USPTODSBDeployment/"
  7. $listName = "DSBUserAssetInformation"
  8. $username = "XXXXXXXXXXX"
  9. $password = Read-Host -Prompt "Enter your Password" -AsSecureString
  10. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
  11. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
  12. $ctx.Credentials = $credentials
  13. #$currentParent = ''
  14. $web = $ctx.Web
  15. $ctx.Load($web)
  16. $ctx.Load($ctx.Web.Lists)
  17. $ctx.ExecuteQuery()
  18. $list = $ctx.Web.Lists.GetByTitle("DSBUserAssetInformation")
  19. $ctx.Load($list)
  20.  
  21. #Start debugging log and path to import data
  22. $docSetExcelSpreadsheet = Import-Csv C:\Users\mbailey3\Documents\Projects\DSBDeploymentProject\PretendDataCSV1.csv -Delimiter ','
  23. $rightNow = Get-Date -format MM-dd-yy-HH-mm-ss
  24.  
  25. $ErrorFileName = "C:\Users\mbailey3\Documents\Projects\DSBDeploymentProject\ErrorLogs" + $rightNow + ".txt"
  26. ForEach ($employee in $employeeAssetExcelSpreadsheet) {
  27. try {
  28. #Modify this line with the Title for your new Document Set
  29. #[Microsoft.SharePoint.Client.DocumentSet.DocumentSet]::Create($ctx, $parentFolder, $docSet.DocSetName, $myContentType.Id)
  30. $listItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
  31. $item = $list.AddItem($listItemInfo)
  32. #write-host $docSet.DocSetName
  33. $ctx.ExecuteQuery()
  34. } catch {
  35. $ErrorMessage = $_.Exception.Message
  36. $FailedItem = $_.Exception.ItemName
  37. write-host "$ErrorMessage $FailedItem"
  38. Add-Content $ErrorFileName "`n $ErrorMessage $FailedItem"
  39. }
  40. }
  41. write-host "Fin"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement