I am a relative newbie to Powershell and I looking for basic code to create a SPO list. I am using SharePointPnPPowerShell. I also need to create columns for the list.
My list name is “Assigned Writers” with column names of “File”, “Writer”, “Due Date”, and “Status”. Any help is greatly appreciated.
Thanks for the response. This looks like what I need. However, I am using PnP Powershell and so the Get-SPWeb is not a valid cmdlet. It throws an error “Not recognized as the name of a cmdlet, function, script file, or operable program”.
How would the code need to be rewritten to replace “$web = Get-SPWeb -Identity $webUrl” to work with PnP Powershell cmdlets?
Get-SPWeb is not a valid cmdlet. It throws an error "Not recognized as the name of a cmdlet, function, script file, or operable program".
For virtually anything dealing with MSOL and PS, you have to download and install the appropriate tools. You must install the SPO module to use the SPO cmdlets. You cannot use the on-prem SP cmdlets to connect to and work on SPO.
Well, I’ve never had a reason to use Pnp PowerShell for anything.
On-prem I use SP and in SPO, I use the SPO version.
Any needed cmdlet for a script must already be on your system or you have to manually install just as you had to do to leverage the PnP module. There is not magic way to auto do this. If the PnP module does not have the requisite cmdlets, then you need to move to a module that does.
You say you are new to PS, then it’s really very important that you get some ramp up on it before you unnecessarily frustrate yourself running into blockers, logic errors or troubleshooting, as you are here. There are lots of beginner to advanced level, no cost training via the MS Viraul Academy, MS TechNet Virtual Labs, and YouTube, as well as a plethora of no cost eBooks on this very site and on MS TechNet.
Looking a that MS Docs papers on the PnP PowerShell topic, just like with the standard SPO module, you have to connect to SPO via PnP with to be able to use the PnP cmdlets.
Connect-PnPOnline
Module:sharepoint-pnpApplies to:
SharePoint Server 2013, SharePoint Server 2016, SharePoint Online
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline?view=sharepoint-ps
However, the docs further stat that…
PnP
PowerShell overview
SharePoint Patterns and Practices (PnP) contains a library of PowerShell commands (PnP PowerShell) that allows you to perform complex provisioning and artifact management actions towards SharePoint. The commands use CSOM and can work against both SharePoint Online as SharePoint On-Premises.
https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps
… and lists the cmdlets that are part of the module.
You ran this…
Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
… which should show you a result of the module is loaded or not.
What you have not run, is…
Get-Command -Name '*pnp*'
… to see the full command list that is in the module. Whether you did the above or just looked at the MS Docs site link above. You’ll instantly see that the cmdlet you are after is not part of the module. In reading the docs, what you are trying to do is what the normal SP/SPO cmdlets are for, not the PnP module, since that is not it’s mission.
The base SP/SPO cmdlets are all about management and administration. The PnP ones are a special Dev use case thing.
Thank you postanote for your detailed response. I got sidetracked on another critical project so my apologies for my slow reply.
I am running Windows 10 and I have the SPO Management Shell installed. I am performing these actions on various SPO sites where I am the site collection admin.
and received this message: “WARNING: Version ‘16.0.8029.0’ of module ‘Microsoft.Online.SharePoint.PowerShell’ is already installed”.
I either must solve how to install this module so I can execute the Get-SPWeb cmdlet OR find alternate code that only uses PowerShellPnP. Any recommendations are appreciated and thanks again for your detailed responses.