Feb 24 2022 01:25 PM
Hello,
Trying to connect to SPO in Powershell. It works in the ISE, does not in VSCode
In VScode I tried this and got:
Connect-SPOService -url https://<Tenant-admin>.sharepoint.com
Connect-SPOService: The term 'Connect-SPOService' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I have done the following
Uninstalled SharePoint Online Management Shell
Reinstalled it
Went into VScode did an Install-Module Microsoft.Online.SharePoint.PowerShell:
WARNING: Version '16.0.22111.0' of module 'Microsoft.Online.SharePoint.PowerShell' is already installed at 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell'.
To install version '16.0.22111.12000', run Install-Module and add the -Force parameter, this command will install version '16.0.22111.12000' side-by-side with version '16.0.22111.0'.
Tried this: get-module | select version,name,path
and get this
Version Name Path
------- ---- ----
7.0.0.0 Microsoft.PowerShell.Management C:\program files\powershell\7\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1
7.0.0.0 Microsoft.PowerShell.Utility C:\program files\powershell\7\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1
2.6.0 MicrosoftTeams C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.6.0\MicrosoftTeams.psm1
1.4.7 PackageManagement C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psm1
2.2.5 PowerShellGet C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1
2.1.0 PSReadLine C:\program files\powershell\7\Modules\PSReadLine\PSReadLine.psm1
0.0 SetMSTeamsReleaseEnvironment C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.6.0\SetMSTeamsReleaseEnvironment.ps1
In the ISE where it works:
PS C:\WINDOWS\system32> get-module | select version,name,path
Version Name Path
------- ---- ----
16.0.21411.12000 Microsoft.Online.SharePoint.PowerShell C:\Users\<USER>\Documents\WindowsPowerShell\Modules\Microsoft.Online.SharePoint.PowerShell\16.0.21411.12000\Microsoft.Online.SharePoint.PowerShell.dll
3.1.0.0 Microsoft.PowerShell.Management C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1
3.1.0.0 Microsoft.PowerShell.Utility C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1
2.0.0 PSReadline C:\Program Files\WindowsPowerShell\Modules\PSReadline\2.0.0\PSReadLine.psm1
ISE PS version:
Name Value
---- -----
PSVersion 5.1.19041.1320
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1320
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
VScode PS
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Looks like have two versions of PS and only 1 that likes Connect-SPOService.
Help?
Thanks,
V
Feb 25 2022 01:44 AM
It does work in VScode, you can use import-module Microsoft.Online.SharePoint.PowerShell to get it working in PS 7 or choose PS 5 when clicking the version in the lower right bar
Feb 25 2022 08:11 AM - edited Feb 25 2022 08:15 AM
Hello@Harm_Veenstra,
Thank you for pointing that out!
I made that change and tried:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
But received this warning:
WARNING: Version '16.0.21411.12000' of module 'Microsoft.Online.SharePoint.PowerShell' is already installed at 'C:\program files\powershell\7\Modules\Microsoft.Online.SharePoint.PowerShell\16.0.21411.12000'. To install version '16.0.22111.12000', run Install-Module and add the -Force parameter, this command will install version '16.0.22111.12000' side-by-side with version '16.0.21411.12000'.
So I tried:
get-module
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest 7.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature…}
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script 1.4.7 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider…}
Script 0.2.0 PowerShellEditorServices.Commands {Clear-Host, ConvertFrom-ScriptExtent, ConvertTo-ScriptExtent, Find-Ast…}
Binary 0.2.0 PowerShellEditorServices.VSCode {Close-VSCodeHtmlContentView, New-VSCodeHtmlContentView, Set-VSCodeHtmlContentView, Show-VSCodeHtmlContentView…}
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…}
Script 2.1.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}
Shouldn't I see Microsoft.Online.SharePoint.PowerShell as a module in VScode?
This error still occurs
Connect-SPOService: The term 'Connect-SPOService' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Thanks again,
V
Feb 25 2022 09:54 AM
Feb 25 2022 10:19 AM
Feb 25 2022 10:23 AM - edited Feb 25 2022 12:09 PM
You type install-module, but I asked if you could try import-module ;) You can view which modules you have installed using get-module -listavailable
Feb 25 2022 01:16 PM
Feb 25 2022 01:27 PM