While using SharePoint online management shell, every time credential needs to be entered to connect to Tenant and is a hindrance for script execution.
There is a round about way to avoid this.
Below script can be used as a function / method inside the intended script: (highlighted is the key line for making it feasible).
$adminUPN=”<login name for tenant / SharePoint admin.>”
$orgName=”<Name of the organization>”
$password = ConvertTo-SecureString “<Password>” -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ($adminUPN, $password)
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $Cred