PowerShell script to create a list within a SharePoint Online site. Before running this script, make sure you are connected to your SharePoint Online environment using the Connect-SPOService cmdlet and have the necessary permissions to create lists within the site.
# Define the SharePoint Online admin URL and the site URL
$adminURL = "https://yourtenant-admin.sharepoint.com"
$siteURL = "https://yourtenant.sharepoint.com/sites/YourSiteName" # Replace with your site's URL
$listName = "NewListName"
# Connect to SharePoint Online
Connect-SPOService -Url $adminURL
# Connect to the SharePoint site
Connect-PnPOnline -Url $siteURL -UseWebLogin
# Create a new SharePoint list
New-PnPTenantSite -Title $listName -Template GenericList
# Disconnect from SharePoint Online
Disconnect-PnPOnline
# Disconnect from SharePoint Online Management Shell
Disconnect-SPOService
Instructions:
Replace the following placeholders in the script with your specific information:
- https://yourtenant-admin.sharepoint.com: Replace with the URL of your SharePoint Online admin center.
- https://yourtenant.sharepoint.com/sites/YourSiteName: Replace with the URL of the SharePoint site where you want to create the list.
- "NewListName": Replace with the desired name for your new list.