Forum Discussion
Sakshi Amla
May 31, 2018Copper Contributor
Error while connecting to SharePoint online tenant through powershell
I am using below code to loop through all site collections in my tenant, search for a specific keyword and export the search results to csv. cls $host.Runspace.ThreadOptions = "ReuseThread" [S...
paulpascha
May 31, 2018Bronze Contributor
The error message you get tells you're passing the wrong arguments to the Tenant Class's constructor. I don't have a quick fix in the code you've listed but I do suggest you to have a look at the available commands in the PnP-PowerShell module. I think this will make your script a lot easier to create and maintain.
For example, the command documented in the article below will list all site collections for you:
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnptenantsite?view=sharepoint-ps
Hope this helps!