Sunday, April 5, 2020

Connect PnP Online Module


Connect PnP Online Module


#(1)_.Load SP Module already installed
$module = 'SharePointPnPPowerShellOnline'
if (!(Get-Module $module))
{
 write-Host "()_.Importing $modue Module" -ForegroundColor DarkYellow
 Import-Module $module
 write-Host "()_.Completed" -ForegroundColor DarkYellow

}else{

write-Host "Cannot locate ($module)"
write-host 'Script will stop, download and install SP Online module first'
Start-Sleep -Seconds 5
break;

}


#(2)_.Connect PnP Online Module
 Try{

#(-)_.Connect PnP Online Module
$orgName = 'CloudSec365'
$url = "https://$orgName-admin.sharepoint.com"
Connect-PnPOnline -Url $url -UseWebLogin;


}catch{

 Write-Warning 'Error has occoured'
 Write-host "Problem FOUND: $($PSItem.ToString())" -f red -b White

  }




Casey DeDeal
Azure Certified Solutions Architect
AWS Certified Cloud Practitioner

https://msazure365.blogspot.com
https://simplepowershell.blogspot.com
https://twitter.com/Message_Talk

No comments:

Post a Comment