When we connect online sharepoint , normal documents direct to using SharePoint Online Management Shell. , but as you know that , it’s hard to make script using only this. It needs to install so as to use it, but it needs to call module.. so I will introduce how to authenticate , connect online sharepoint in my environment.
Read-Host -Prompt “Enter password to be encrypted in sharepoint online mypassword.txt” -AsSecureString | ConvertFrom-SecureString | out-file “c:\sharepoint365connect.txt” [user input password stores as secure string to the file]
$password = cat “c:\sharepoint365connect.txt”| ConvertTo-SecureString
$auth = “global_admin_account” [get content value from txt file then convert string value]
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $auth,$password [new instance of powershell credential with user id and password ]
Import-Module Microsoft.Online.SharePoint.PowerShell [load online sharepoint module]
Connect-SPOService -url https://cloudwide1603-admin.sharepoint.com -Credential $mycred [connect online sharepoint admin center]
You must input your credentials to connect sharepoint online module after then you can create , edit, sort of workings on the powershell. And there are more method to connect online sharepoint. You need to make your own method I hope.