On this article, we delve into the world of SharePoint PowerShell, exploring its capabilities for environment friendly administration, automation, and customization. Be a part of us as we unlock the total potential of SharePoint by the ability of PowerShell, empowering you to successfully handle and optimize your SharePoint surroundings.
To put in the PowerShell SharePoint On-line module, you possibly can comply with these steps:
- Open a PowerShell session with administrative privileges.
- Run the next command to put in the SharePoint On-line Administration Shell module:
Set up-Module -Title Microsoft.On-line.SharePoint.PowerShell

- If prompted to put in from an untrusted repository, you possibly can proceed by typing “Y” and urgent Enter.
- Look forward to the module to be downloaded and put in in your system.
- As soon as the set up is full, you possibly can import the module utilizing the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- This can make the SharePoint On-line cmdlets accessible to be used in your PowerShell session.
After putting in and importing the module, you possibly can connect with SharePoint On-line utilizing the Join-SPOService
cmdlet and begin managing your SharePoint On-line surroundings by PowerShell.
Administrator Account with out MFA
To connect with SharePoint On-line utilizing PowerShell with an administrator account that doesn’t have multi-factor authentication (MFA) enabled, you possibly can comply with these steps:
- Open a PowerShell session with administrative privileges.
- Import the SharePoint On-line Administration Shell module by operating the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- Connect with SharePoint On-line by operating the next command:
Join-SPOService -Url "https://your-domain-admin.sharepoint.com" -Credential (Get-Credential)

- Change the area URL abovea with the URL of your SharePoint On-line administration web site.
- When prompted, enter the credentials of the administrator account that doesn’t have MFA enabled. This can set up a connection to SharePoint On-line.
After efficiently connecting, you need to use the SharePoint On-line cmdlets to handle your SharePoint surroundings utilizing PowerShell.
Administrator Account with MFA
- Open a brand new PowerShell session.
- Run the next instructions to connect with SharePoint On-line:
# Import the required modules
Import-Module -Title SharePointPnPPowerShellOnline
# Connect with SharePoint On-line
Join-PnPOnline -Url "https://your-domain.sharepoint.com/websites/your-site" -UseWebLogin

- Change the area identify with the URL of your SharePoint On-line web site.
- An indication-in dialog field will seem, prompting you to authenticate together with your administrator account. Comply with the prompts to finish the authentication course of, together with any MFA verification steps.
To create a brand new SharePoint web site utilizing PowerShell and the SharePoint On-line Administration Shell, you possibly can comply with these steps:
- Open PowerShell with administrative privileges.
- Import the SharePoint On-line Administration Shell module by operating the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- Connect with your SharePoint On-line surroundings by operating the next command:
Join-SPOService -Url https://your-domain-admin.sharepoint.com

- Change the instance area above with the URL of your SharePoint On-line admin web site.
- Create a brand new SharePoint web site utilizing the
New-SPOSite
cmdlet. Specify the required parameters for the brand new web site, such because the title, URL, template, and storage quota. Right here’s an instance command:
New-SPOSite -Title "New Website" -Url https://your-domain.sharepoint.com/websites/newsite -Template "STS#0" -StorageQuota 1000

- Change the instance area given above with the specified URL to your new web site. You can too customise the opposite parameters as per your necessities.
- PowerShell will immediate you to supply your SharePoint On-line administrator credentials. Enter the username and password to your administrator account.
- As soon as the command executes efficiently, the brand new SharePoint web site might be created.
Website Group Technology
To generate web site teams utilizing PowerShell and the SharePoint On-line Administration Shell, you possibly can comply with these steps:
- Open PowerShell with administrative privileges.
- Import the SharePoint On-line Administration Shell module by operating the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- Connect with your SharePoint On-line surroundings by operating the next command:
Join-SPOService -Url https://your-domain-admin.sharepoint.com

- Change the instance area given above with the URL of your SharePoint On-line admin web site.
- Retrieve the SharePoint web site the place you need to generate the teams by operating the next command:
$web site = Get-SPOSite -Identification https://your-domain.sharepoint.com/websites/yoursite

- Change the instance area given above with the URL of the goal SharePoint web site.
- Generate a brand new SharePoint group utilizing the
New-SPOSiteGroup
cmdlet. Specify the required parameters for the group, such because the identify, proprietor, and permissions. Right here’s an instance command:
New-SPOSiteGroup -Website $web site -Group "New Group" -Proprietor "proprietor@your-domain.onmicrosoft.com" -PermissionLevels "Learn", "Contribute"

- Change “New Group” with the specified identify to your group, and the instance mail deal with with the e-mail deal with of the group proprietor. You can too customise the permission ranges based mostly in your necessities.
- Repeat the earlier step for every group you need to generate.
Making Website Customers Lists
To create web site consumer lists utilizing PowerShell and the SharePoint On-line Administration Shell, you possibly can comply with these steps:
- Open PowerShell with administrative privileges.
- Import the SharePoint On-line Administration Shell module by operating the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- Connect with your SharePoint On-line surroundings by operating the next command:
Join-SPOService -Url https://your-domain-admin.sharepoint.com

- Change the instance URL with the URL of your SharePoint On-line admin web site.
- Retrieve the SharePoint web site the place you need to create the consumer checklist by operating the next command:
$web site = Get-SPOSite -Identification https://your-domain.sharepoint.com/websites/yoursite

- Change the area identify with the URL of the goal SharePoint web site.
- Create a brand new SharePoint checklist utilizing the
New-SPOList
cmdlet. Specify the required parameters for the checklist, such because the title and template sort. Right here’s an instance command to create a customized checklist:
New-SPOList -Website $web site -Title "Person Checklist" -Template "Customized Checklist"

- Change “Person Checklist” with the specified title to your checklist and “Customized Checklist” with the suitable template sort.
Blacklist Customers from Website Teams
To blacklist customers from SharePoint web site teams utilizing PowerShell and the SharePoint On-line Administration Shell, you possibly can comply with these steps:
- Open PowerShell with administrative privileges.
- Import the SharePoint On-line Administration Shell module by operating the next command:
Import-Module -Title Microsoft.On-line.SharePoint.PowerShell

- Connect with your SharePoint On-line surroundings by operating the next command:
Join-SPOService -Url https://your-domain-admin.sharepoint.com

- Change “https://your-domain-admin.sharepoint.com” with the URL of your SharePoint On-line admin web site.
- Retrieve the SharePoint web site the place the location group exists by operating the next command:
$web site = Get-SPOSite -Identification https://your-domain.sharepoint.com/websites/yoursite

- Change the instance hyperlink with the URL of the goal SharePoint web site.
- Retrieve the location group from which you need to blacklist customers by operating the next command:
$group = Get-SPOSiteGroup -Website $web site -Identification "Group Title"

- Change “Group Title” with the identify of the location group.
- Retrieve the consumer(s) that you just need to blacklist from the location group by operating the next command:
$consumer = Get-SPOUser -Website $web site -LoginName "consumer@area.com"

- Change the instance electronic mail deal with with the login identify of the consumer you need to blacklist.
- Add the consumer(s) to thwe blacklist of the location group by operating the next command:
Set-SPOSiteGroup -Website $web site -Group $group -DenyAddAndCustomizePages -AddUserOnly -AddUser $consumer

- This command provides the consumer(s) to the location group blacklist, stopping them from including or customizing pages within the web site.
PowerShell SharePoint On-line automation refers to using PowerShell scripting to automate duties and operations in SharePoint On-line, which is a part of the Microsoft 365 suite. PowerShell offers a strong and environment friendly option to handle and administer SharePoint On-line, permitting you to carry out varied actions programmatically.
PowerShell SharePoint On-line automation helps you save time, improve effectivity, and preserve consistency in managing your SharePoint On-line surroundings. It’s notably helpful for organizations with complicated or large-scale SharePoint deployments that require frequent administration and upkeep duties.
With PowerShell SharePoint On-line automation, you possibly can streamline and expedite frequent administrative duties, carry out bulk operations, implement governance insurance policies, and obtain constant configurations throughout your SharePoint On-line surroundings. Listed below are some examples of what you possibly can automate:
- Website provisioning
- Checklist and library administration
- Person and group administration
- Content material migration
- Website customization
- Workflow automation
- Reporting and monitoring
To carry out SharePoint On-line automation utilizing PowerShell, you must set up the SharePoint On-line Administration Shell module and set up a connection to your SharePoint On-line surroundings utilizing the Join-SPOService cmdlet. As soon as related, you need to use varied SharePoint On-line cmdlets to work together with websites, lists, customers, permissions, and extra.