Some of you may have noticed my recent posts on some questions in the forum. Here’s another one… 🙂
I’m trying to create some deployment scripts using PowerShell. I’m able to connect to my tenant but am not able to do much with it afterwards. Any thoughts?
Add-Type -Path “C:\dll\Microsoft.SharePoint.Client.dll”
Add-Type -Path “C:\dll\Microsoft.SharePoint.Client.Runtime.dll”
Add-Type -Path “C:\dll\Microsoft.SharePoint.Client.Taxonomy.dll”
$tenantAdmin = “https://tenant-admin.sharepoint.com”
$tenantRoot = “https://tenant.sharepoint.com”
$adminUser = “haniel@tenant.onmicrosoft.com”
$password = “password”
 
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($adminUser, $securePassword)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($tenantRoot)
$ctx.Credentials = $credentials
$webs = $ctx.Web
$ctx.Web or other objects I’m trying to access come back as null. Any thoughts?
Seems like the error is communicating that Windows Powershell version 5 (is it out of preview yet?) may not be registered properly on the environment where you are running the script from… that’s what I would check first, or maybe back down to a different version of powershell possibly if version 5 is still in a preview state. Sorry I don’t have anything concrete on this issue for you to go to or try out.
Dave