%3CLINGO-SUB%20id%3D%22lingo-sub-1546527%22%20slang%3D%22en-US%22%3EHow%20to%20Manage%20SharePoint%20via%20PowerShell%20-%20Part%201%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546527%22%20slang%3D%22en-US%22%3E%3CDIV%3E%3CSPAN%3EIn%20this%20two-part%20series%2C%20we're%20going%20to%20look%20at%20how%20we%20can%20manage%20SharePoint%20using%20PowerShell.%20This%20is%20highly%20focused%20on%20SharePoint%20Online%2C%20but%20if%20the%20cmdlets%20are%20available%2C%20it%20also%20applies%20to%20SharePoint%20on-premises.%20We'll%20start%20with%20the%20basics%2C%20and%20then%20get%20some%20real-world%20scenarios%20scripts%20in%20part%202%20to%20get%20you%20started%20with%20your%20daily%20management%20tasks.%20I'll%20also%20you%20give%20some%20tips%20along%20the%20way%20to%20make%20your%20life%20easier.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3ELet%20me%20start%20by%20asking%20this%3A%20Have%20you%20ever%20been%20curious%20enough%20to%20look%20at%20how%20many%20SharePoint%20on-premises%20PowerShell%20cmdlets%20are%20available%3F%20If%20not%2C%20I%20can%20tell%20you%20there%20are%20800%2B%20of%20them.%20Now%2C%20have%20you%20been%20curious%20enough%20to%20look%20at%20how%20many%20PowerShell%20cmdlets%20are%20available%20to%20manage%20SharePoint%20Online%3F%20%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22numOfCmdlets.png%22%20style%3D%22width%3A%20636px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207975i391E682C2C403922%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22numOfCmdlets.png%22%20alt%3D%22numOfCmdlets.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EWell%2C%20that's%20a%20big%20drop%20isn't%20it%3F!%20In%20SharePoint%20on-premises%2C%20there%20are%20a%20lot%20of%20commands%20to%20configure%20Search%2C%20Service%20Applications%2C%20interact%20with%20SQL%20databases%2C%20or%20other%20features%20provided%20by%20SharePoint.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EWith%20SharePoint%20Online%2C%20we%20don't%20need%20to%20do%20all%20that.%20Microsoft%20manages%20everything%2C%20and%20we%20don't%20need%20to%20worry%20about%20databases%20for%20instance.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH2%20id%3D%22toc-hId--1298038443%22%20id%3D%22toc-hId--1298038443%22%3E%3CSPAN%3ESo%2C%20what%20now%3F%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EThere%20is%20%3C%2FSPAN%3E%3CEM%3Eanother%3C%2FEM%3E%3CSPAN%3E%20PowerShell%20module%20out%20there...%20And%20if%20you've%20never%20heard%20of%20it%2C%20you're%20totally%20missing%20out!%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2FPnP-PowerShell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESharePoint%20PowerShell%20PnP%3C%2FA%3E%20%3C%2FSPAN%3E%3CSPAN%3E(Patterns%20%26amp%3B%20Practices)%20is%20a%20module%20created%20by%20a%20community%20member%20(Erwin%20Van%20Hunen%2C%20MVP)%20to%20fill%20a%20gap%20in%20the%20management%20of%20SharePoint%20when%20using%20only%20PowerShell.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ECurrently%2C%20there%20are%20492%20cmdlets%20available%20(v.3.23.2007.1)%20and%20the%20prefix%20used%20is%20'PnP'%20(%3C%2FSPAN%3E%3CEM%3Ei.e.%3A%20Get-PnPList%3C%2FEM%3E%3CSPAN%3E).%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EIf%20you%20don't%20have%20a%20native%20cmdlet%2C%20you%20can%20still%20use%20%3C%2FSPAN%3E%3CEM%3EClient-Side%20Object%20Model%20(CSOM)%3C%2FEM%3E%3CSPAN%3E%3CEM%3E%2C%3C%2FEM%3E%20or%20%3C%2FSPAN%3E%3CEM%3EServer-Side%20Object%20Model%20(SSOM)%3C%2FEM%3E%3CSPAN%3E.%20However%2C%20as%20administrators%2C%20we%20might%20know%20PowerShell%2C%20but%20not%20be%20proficient%20in%20the%20other%20methods.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3E%3CU%3ENote%3C%2FU%3E%3A%20In%20this%20module%2C%20you'll%20also%20notice%20that%20there%20are%20%3CSTRONG%3EMicrosoft%20Teams%20cmdlets%3C%2FSTRONG%3E%2C%20which%20are%20starting%20to%20surface%20with%20the%20July%202020%20version!%3C%2FEM%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CH2%20id%3D%22toc-hId-1189474390%22%20id%3D%22toc-hId-1189474390%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--617980073%22%20id%3D%22toc-hId--617980073%22%3EHow%20can%20I%20use%20it%3F%3C%2FH2%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3ETo%20start%20benefiting%20from%20this%20great%20module%2C%20we%20first%20need%20to%20install%20it.%20We%20have%20a%20few%20ways%20to%20do%20that.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CUL%20class%3D%22lia-list-style-type-circle%22%3E%0A%3CLI%3E%3CSPAN%3EDownload%20the%20.msi%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EInstall%20from%20the%20PowerShell%20Gallery%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EThis%20module%20is%20available%20for%20SharePoint%202013%2F2016%2F2019%2C%20and%20SharePoint%20Online.%20It's%20important%20to%20refer%20to%20the%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2F%3Fview%3Dsharepoint-ps%26amp%3B%3FWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3Eofficial%20documentation%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%20because%20some%20commands%20might%20be%20available%20for%20a%20module%20but%20not%20the%20other.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EOnce%20installed%20with%20your%20favorite%20method%2C%20we%20need%20to%20connect%20to%20SharePoint%20Online%20(%3C%2FSPAN%3E%3CEM%3Emake%20sure%20you've%20got%20at%20least%20the%20SharePoint%20admin%20role%20assigned%3C%2FEM%3E%3CSPAN%3E).%20Depending%20on%20the%20action%20we%20want%20to%20perform%2C%20we%20can%20connect%20to%20the%20SharePoint%20Admin%20Center%2C%20or%20to%20a%20particular%20site.%20At%20its%20most%20basic%20form%2C%20connecting%20would%20look%20like%20this%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24creds%20%3D%20Get-Credential%0A%0AConnect-PnPOnline%20-Url%20%22https%2F%2F%3CTENANT-NAME%3E.sharepoint.com%2Fsites%2F%3CYOUR-SITE%3E%22%20-Credential%20%24creds%E2%80%8B%3C%2FYOUR-SITE%3E%3C%2FTENANT-NAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%20class%3D%22lia-spoiler-container%22%3E-ERR%3AREF-NOT-FOUND-Spoiler%3CNOSCRIPT%3E%20(Highlight%20to%20read)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CEM%3E%3CSTRONG%3EWant%20a%20tip%3F%3C%2FSTRONG%3E%20If%20you%20enter%20your%20credentials%20in%20your%20Windows%20Credential%20Manager%20under%20%22Windows%20Credentials%20--%26gt%3B%20Add%20a%20generic%20credential%22%2C%20you%20won't%20need%20to%20use%20the%20-Credential%20parameter!%3C%2FEM%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3EWant%20a%20tip%3F%20If%20you%20enter%20your%20credentials%20in%20your%20Windows%20Credential%20Manager%20under%20%22Windows%20Credentials%20--%26gt%3B%20Add%20a%20generic%20credential%22%2C%20you%20won't%20need%20to%20use%20the%20-Credential%20parameter!%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EIf%20your%20account%20has%20multi-factor%20authentication%20(MFA)%20enabled%2C%20use%20the%20%3C%2FSPAN%3E%3CSTRONG%3E-UseWebLogin%3C%2FSTRONG%3E%3CSPAN%3E%20parameter.%20I'd%20encourage%20you%20to%20visit%20the%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fconnect-pnponline%3Fview%3Dsharepoint-ps%26amp%3Bhttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2F%3Fview%3Dsharepoint-ps%26amp%3B%3FWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EConnect-PnPOnline%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%20documentation%20because%20there%20are%20plenty%20of%20other%20ways%20to%20connect!%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CH2%20id%3D%22toc-hId-1869532760%22%20id%3D%22toc-hId-1869532760%22%3E%3CSPAN%3EConnect%20to%20the%20SharePoint%20Admin%20Center%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EDepending%20on%20which%20site%20you're%20connected%20to%2C%20you%20get%20different%20results.%20What%20I%20mean%20is%2C%20by%20connecting%20to%20the%20SharePoint%20Admin%20Center%20you%20won't%20be%20able%20to%20interact%20much%20with%20library%20content%2C%20or%20fields.%20But%20connecting%20to%20the%20Admin%20Center%20can%20give%20us%20information%20about%20the%20tenant%20settings.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CBR%20%2F%3E%0A%3CDIV%3E%3CSPAN%3ELet's%20connect%20to%20the%20Admin%20Center%2C%20and%20run%20%3C%2FSPAN%3E%3CEM%3EGet-PnPTenant%3C%2FEM%3E%3CSPAN%3E%20to%20get%20some%20information%20at%20the%20tenant%20level.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EConnect-PnPOnline%20-Url%20%22https%3A%2F%2Fm365x141782-admin.sharepoint.com%2F%22%0AGet-PnPTenant%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22GetPnPTenant.png%22%20style%3D%22width%3A%20712px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207978i663F0735D0D1357E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22GetPnPTenant.png%22%20alt%3D%22GetPnPTenant.png%22%20%2F%3E%3C%2FSPAN%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EAs%20we%20are%20connected%20to%20the%20top-level%20site%20(admin%20one)%2C%20we%20can%20also%20get%20all%20our%20site%20collections%20using%20the%20%3C%2FSPAN%3E%3CEM%3EGet-PnPTenantSite%3C%2FEM%3E%3CSPAN%3E%20cmdlet.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22GetPnPTenantSite.png%22%20style%3D%22width%3A%20943px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207979iA0C56440E0BA0E91%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22GetPnPTenantSite.png%22%20alt%3D%22GetPnPTenantSite.png%22%20%2F%3E%3C%2FSPAN%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CH2%20id%3D%22toc-hId-62078297%22%20id%3D%22toc-hId-62078297%22%3E%3CSPAN%3EConnect%20to%20a%20Specific%20SharePoint%20Site%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CDIV%3E%3CSPAN%3EThis%20is%20where%20you're%20going%20to%20send%20most%20of%20your%20requests.%20Use%20the%20following%20to%20connect%20to%20your%20target%20site%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EConnect-PnPOnline%20-Url%20%22https%3A%2F%2Fm365x141782.sharepoint.com%2Fsites%2FContoso%22%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CBR%20%2F%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EAgain%20here%2C%20I'm%20%3CSTRONG%3Enot%20%3C%2FSTRONG%3Eusing%20the%20%3C%2FSPAN%3E%3CEM%3E-Credential%3C%2FEM%3E%3CSPAN%3E%20parameter%20because%20my%20credentials%20are%20stored%20in%20the%20Credential%20Manager%20on%20my%20machine.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CBR%20%2F%3E%0A%3CDIV%3E%0A%3CDIV%20class%3D%22lia-spoiler-container%22%3E-ERR%3AREF-NOT-FOUND-Spoiler%3CNOSCRIPT%3E%20(Highlight%20to%20read)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CEM%3E%3CSTRONG%3EWant%20a%20Tip%3F%3C%2FSTRONG%3E%20If%20you%20ever%20forget%20on%20which%20site%20you're%20connected%20to%2C%20you%20can%20run%20%60Get-PnPContext%60%2C%20and%20look%20at%20the%20'Url'%20property.%3C%2FEM%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3EWant%20a%20Tip%3F%20If%20you%20ever%20forget%20on%20which%20site%20you're%20connected%20to%2C%20you%20can%20run%20%60Get-PnPContext%60%2C%20and%20look%20at%20the%20'Url'%20property.%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CBR%20%2F%3E%0A%3CDIV%3E%3CSPAN%3EThat's%20it%20for%20this%20first%20part.%20Part%202%20will%20explore%20how%20to%20interact%20with%20sites%20content!%20Stay%20tuned.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1546527%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EIn%20this%20two-part%20series%2C%20we're%20going%20to%20look%20at%20how%20we%20can%20manage%20SharePoint%20using%20PowerShell.%20This%20is%20highly%20focused%20on%20SharePoint%20Online%2C%20but%20if%20the%20cmdlets%20are%20available%2C%20it%20also%20applies%20to%20SharePoint%20on-premises.%20We'll%20start%20with%20the%20basics%2C%20and%20then%20get%20some%20real-world%20scenarios%20scripts%20in%20part%202%20to%20get%20you%20started%20with%20your%20daily%20management%20tasks.%20I'll%20also%20you%20give%20some%20tips%20along%20the%20way%20to%20make%20your%20life%20easier.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22managing-sharepoint-with-powershell.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F208194iCB1B9BAEBE2A47DF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22managing-sharepoint-with-powershell.png%22%20alt%3D%22managing-sharepoint-with-powershell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1546527%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVeronique%20Lengelle%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
In this two-part series, we're going to look at how we can manage SharePoint using PowerShell. This is highly focused on SharePoint Online, but if the cmdlets are available, it also applies to SharePoint on-premises. We'll start with the basics, and then get some real-world scenarios scripts in part 2 to get you started with your daily management tasks. I'll also you give some tips along the way to make your life easier.

 

Let me start by asking this: Have you ever been curious enough to look at how many SharePoint on-premises PowerShell cmdlets are available? If not, I can tell you there are 800+ of them. Now, have you been curious enough to look at how many PowerShell cmdlets are available to manage SharePoint Online?
 
numOfCmdlets.png

 

 

Well, that's a big drop isn't it?! In SharePoint on-premises, there are a lot of commands to configure Search, Service Applications, interact with SQL databases, or other features provided by SharePoint.

With SharePoint Online, we don't need to do all that. Microsoft manages everything, and we don't need to worry about databases for instance.
 

So, what now?

There is another PowerShell module out there... And if you've never heard of it, you're totally missing out!

SharePoint PowerShell PnP (Patterns & Practices) is a module created by a community member (Erwin Van Hunen, MVP) to fill a gap in the management of SharePoint when using only PowerShell.

Currently, there are 492 cmdlets available (v.3.23.2007.1) and the prefix used is 'PnP' (i.e.: Get-PnPList).

If you don't have a native cmdlet, you can still use Client-Side Object Model (CSOM), or Server-Side Object Model (SSOM). However, as administrators, we might know PowerShell, but not be proficient in the other methods.

Note: In this module, you'll also notice that there are Microsoft Teams cmdlets, which are starting to surface with the July 2020 version!

 

How can I use it?

To start benefiting from this great module, we first need to install it. We have a few ways to do that.

  • Download the .msi
  • Install from the PowerShell Gallery

This module is available for SharePoint 2013/2016/2019, and SharePoint Online. It's important to refer to the official documentation because some commands might be available for a module but not the other.

Once installed with your favorite method, we need to connect to SharePoint Online (make sure you've got at least the SharePoint admin role assigned). Depending on the action we want to perform, we can connect to the SharePoint Admin Center, or to a particular site. At its most basic form, connecting would look like this:
$creds = Get-Credential

Connect-PnPOnline -Url "https//<TENANT-NAME>.sharepoint.com/sites/<YOUR-SITE>" -Credential $creds​
 
Spoiler
Want a tip? If you enter your credentials in your Windows Credential Manager under "Windows Credentials --> Add a generic credential", you won't need to use the -Credential parameter!
If your account has multi-factor authentication (MFA) enabled, use the -UseWebLogin parameter. I'd encourage you to visit the Connect-PnPOnline documentation because there are plenty of other ways to connect!
 

Connect to the SharePoint Admin Center

Depending on which site you're connected to, you get different results. What I mean is, by connecting to the SharePoint Admin Center you won't be able to interact much with library content, or fields. But connecting to the Admin Center can give us information about the tenant settings.

Let's connect to the Admin Center, and run Get-PnPTenant to get some information at the tenant level.
 
Connect-PnPOnline -Url "https://m365x141782-admin.sharepoint.com/"
Get-PnPTenant​
GetPnPTenant.png

 

As we are connected to the top-level site (admin one), we can also get all our site collections using the Get-PnPTenantSite cmdlet.
GetPnPTenantSite.png

 

Connect to a Specific SharePoint Site

This is where you're going to send most of your requests. Use the following to connect to your target site:
 
Connect-PnPOnline -Url "https://m365x141782.sharepoint.com/sites/Contoso"

Again here, I'm not using the -Credential parameter because my credentials are stored in the Credential Manager on my machine.

Spoiler
Want a Tip? If you ever forget on which site you're connected to, you can run `Get-PnPContext`, and look at the 'Url' property.

That's it for this first part. Part 2 will explore how to interact with sites content! Stay tuned.