0

I have a couple of PowerShell scripts that can run using Windows PowerShell with no issue.

As soon as I run them in VS Code on the same computer, I get "Connect-MsGraph' is not recognized as the name of a cmdlet,

I have installed the same Microsoft.Graph.Intune and other relevant AAD modules for both Windows PowerShell and VS Code.

Any idea why I can't run them in the VS Code?

Thanks

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
nhtkid
  • 1
  • 1
  • 1

1 Answers1

0

Connect-MsGraph' is not recognized as the name of a cmdlet,

The issue happens because of the VS code is not able to access the PSModulePath in the system or it happens if you are not using the latest Microsoft.Graph SDK.

Try to install the module in a default path

    Install-Module -Name Microsoft.Graph -RequiredVersion 1.2.0

Refer here if in your system default path contains OneDrive.

After adding the required modules in a default path try to restart the VS Code and System.

References

Roshan
  • 2,604
  • 2
  • 15
  • 13
Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
  • Hi DelliganeshS-MT, Thanks for the suggestion. I checked my system variables. I have the %Programs%\WindowsPowerShell\Modules as default PSModulePath. I checked the folder and can also confirm modules are actually there. I also have OneDrive so I added my OneDrive Path too. I also tried the Install-Module cmd with required version, still getting the same error so far. One thing to mention is I am a standard user and not running VS Code as local admin. – nhtkid Jun 14 '22 at 11:26
  • We can able to run the PowerShell script in VS code. Can you try to reinstall the VS code once. – Delliganesh Sevanesan Jun 14 '22 at 13:43