msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Importing Microsoft.Graph modules in scope CurrentUser fails if OneDrive folder name contains : '
While trying to work with the Ms Graph powershell SDK, i get errors importing modules :
PS U:> Import-Module -Name Microsoft.Graph $ParseException/ à System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents) à System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script) à System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script, Boolean useNewScope, PipelineResultTypes wri teToPipeline, IList input, Object[] args) à Microsoft.Graph.PowerShell.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script) à Microsoft.Graph.PowerShell.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder) à Microsoft.Graph.PowerShell.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord() AVERTISSEMENT : Selected Microsoft Graph profile 'v1.0' does not exist for module 'Microsoft.Graph.WindowsUpdates'. No cmdlets were lo aded. Import-Module : Au caractère Ligne:3 : 189
- ... m' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Le terminateur ' est manquant dans la chaîne. <<< The terminator ' is missing in the string Au caractère Ligne:1 : 1
- Import-Module -Name Microsoft.Graph
-
+ CategoryInfo : ParserError: (:) [Import-Module], ParseException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString,Microsoft.PowerShell.Commands.ImportModuleCommand
The modules are imported to my OneDrive because my folders are redirected, and the path is : C:\Users<My Username>\OneDrive\OneDrive - Ministère de l'économie\Documents\WindowsPowerShell\Modules (Notice the ' in the OneDrive folder name).
As such, it means i need admin access to install the modules in global scope ; its impossible to use in user Scope because of the special character.
Note : Other non MicrosoftGraph modules work fine ; which is why I'm posting the issue here.
@remygs, sorry about this, and thanks for surfacing the error with us. I can confirm that it is a bug with how our code generator parses the module path when importing modules.
As a workaround, I suggest installing the module system-wide as we work to fix this bug - Install-Module Microsoft.Graph -Scope AllUsers.
Will be fixed by https://github.com/Azure/autorest.powershell/issues/845.
Fixed by https://github.com/Azure/autorest.powershell/issues/845. Will ship in v2.