Sharepoint Online PowerShell Script add item list
Error:
Excepción al llamar a "ExecuteQuery" con los argumentos "0": "The sign-in name or password does not match one in the
Microsoft account system."
ADR Tutorials
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
$SiteURL = "https://CompanySite.sharepoint.com/sites/YourSite/"
$ListName="Datos"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$securePassword=ConvertTo-SecureString "Type password Here" -AsPlainText -Force
$Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("user@CompanySite.com", $securePassword)
$Web = $Context.Web
$List = $web.get_lists().getByTitle($ListName)
$itemCreateInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$CurrentDay1 = Get-Date -Format "dd"
$CurrenttMonth = Get-Date -Format "MM"
$listItem = $list.addItem($itemCreateInfo)
$listItem.set_item('Title', 'Item Title')
$listItem.set_item('Description', $CurrentDay1 + '-' + $CurrenttMonth)
$listItem.update();
$Context.Load($listItem)
$Context.ExecuteQuery()
No hay comentarios:
Publicar un comentario