12-12-2020 10:40 AM
12-12-2020 10:40 AM
installed PowerShell 7.1
Running Microsoft Sharepoint Online command "connect-SPOService" using elevated session does not work when running PowerShell 7.1, but does work when running Windows PowerShell
Does anyone know why the connect-SPOService wouls not run on PWSH 7.1? I installed this core version because I read everywhere (as well as in training videos) that one should not use Windows PowerShell. But, to my frustration, the cmdlet 'Connect-SPOService' does not run on PWSH 7.1
12-12-2020 12:02 PMSolution
The module is not supported on PSCore/7.1, it has dependencies on .Net libraries which are not supported there. It should run fun in compatibility mode though (use the UseWindowsPowerShell switch with Import-Module).
12-14-2020 02:44 AM
@Vasil Michev thank you for your clear answer!
Interesting fact: I was following advice in an e-book for PowerShell beginners, where I followed every step of the given advice; the e-book clearly indicated that one should use PWS 7.1.
So I really hope that your reply will be read by many other PWS starters!!
12-14-2020 05:36 AM
This is a challenge. Since PowerShell 7.1 uses .NET 5, cmdlets/modules you run must work against that version of .NET Core. There are some older modules that work fine in Pwsh 7.1, but many do not. With 7.0, the team built a compatibility mechanism into Import-Module which crates a remoting session to the local host connecting to a WIndows PowerShell remoting configuration. Then, it loads the module into the remote session and then uses implicit remoting to create local functions you can then use.
So if you use Install-WIndowsFeature, then, the module is loaded in a compatibility session and you see local functions. About the only downside is that the Format XML is not carried forward, but you can fix that manually by importing the XML file from the module's folder
But Some modules do not load properly - such as Best Practices. Three modules are blocked from being loaded via a JSON file in the pwsh $home folder. And some modules appear to work but don't. And finally, a few modules, like updates services (with WSUS) do not work at all via PowerShell 7 - use WIndows PowerShell for those scripts
12-15-2020 02:46 AM
@Thomas Lee Dear Thomas, thank you for the added detail and clarification.
Reviewing what I now understand, I reach the conclusion that PWS 7.1 is really not fit for purpose: to be a suitable follow up for Microsoft PowerShell 5.1.
PWS 7.1 has advantages and may be the way forward (due to multiplatform capability), but it realy does not qualify as a replacement yet as long as it does not work 'out-of-the-box' for SPO or PnP sharepoint online modules. It does allow to use the MicrosoftTeams module, but that is not enough to replace a graphical interface if you want to customize a clients Teams + SharePoint environment.
I would welcome if the PowerShell Community would make clarifications like the one given by Tomas about the limitation of PWS 7 clear and easy to find for everyone who starts using PowerShell. It took me many, many hours to understand why all the magic did not work!