-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Hello.
I'm not sure this bug is related to #4193, or it's a different one.
I'm seeing an issue where PowerShell fails to import modules if the file path contains an apostrophe when used with OneDrive for Business, where tenant name includes an apostrophe (e.g., C:\Users\Name\OneDrive - Company's Name\Documents\...).
If the same modules are installed with -Scope AllUsers, they load fine. However, this requires running PowerShell with admin privileges, which sometimes is not feasible.
Expected behavior
Script should be able to import modules and run properly.Actual behavior
PS C:\Users\UserName> Install-Module ZeroTrustAssessment
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\Users\UserName> Connect-ZtAssessment
$ParseException/ at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ScriptBlock.Create(ExecutionContext context, String script)
at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(String script)
at Microsoft.Graph.PowerShell.PSCmdletExtensions.RunScript[T](CommandInvocationIntrinsics cii, String script)
at Microsoft.Graph.PowerShell.PSCmdletExtensions.RunScript[T](PSCmdlet cmdlet, String script)
at Microsoft.Graph.PowerShell.Authentication.Utilities.Runtime.Cmdlets.GetScriptCmdlet.GetScriptCmdlets(String scriptFolder)
at Microsoft.Graph.PowerShell.Authentication.Utilities.Runtime.Cmdlets.GetScriptCmdlet.ProcessRecord()
$IncompleteParseException/ at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T]()
at Microsoft.Graph.PowerShell.PSCmdletExtensions.RunScript[T](String script)
at Microsoft.Graph.PowerShell.Authentication.Utilities.Runtime.Cmdlets.GetModuleCmdlet.GetModuleCmdlets(String modulePath)
at Microsoft.Graph.PowerShell.Authentication.Utilities.Runtime.Cmdlets.GetModuleCmdlet.ProcessRecord()
Connect-ZtAssessment: The 'Connect-ZtAssessment' command was found in the module 'ZeroTrustAssessment', but the module could not be loaded. For more information, run 'Import-Module ZeroTrustAssessment'.
PS C:\Users\UserName> Import-Module ZeroTrustAssessment
PS C:\Users\UserName> Connect-ZtAssessment
Connecting to Microsoft Graph
The Graph PowerShell module is not installed. Please install the module using the following command. For more information see https://learn.microsoft.com/powershell/microsoftgraph/installation
Install-Module Microsoft.Graph -Scope CurrentUser
Connecting to Azure
Connect-AzAccount: C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1:106
Line |
106 | Connect-AzAccount @azParams
| ~~~~~~~~~
| Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
PS C:\Users\UserName> Install-Module Microsoft.Graph -Scope CurrentUser
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you
want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\Users\UserName> Connect-ZtAssessment
Connecting to Microsoft Graph
The Graph PowerShell module is not installed. Please install the module using the following command. For more information see https://learn.microsoft.com/powershell/microsoftgraph/installation
Install-Module Microsoft.Graph -Scope CurrentUser
Connecting to Azure
Connect-AzAccount: C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1:106
Line |
106 | Connect-AzAccount @azParams
| ~~~~~~~~~
| Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
PS C:\Users\UserName>Error details
Exception :
Type : System.Management.Automation.ParameterBindingValidationException
Message : Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
ParameterName : Tenant
ParameterType : [System.String]
ErrorId : ParameterArgumentValidationError
Line : 106
Offset : 31
CommandInvocation :
MyCommand : Connect-AzAccount
ScriptLineNumber : 106
OffsetInLine : 13
HistoryId : 7
ScriptName : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
Line : Connect-AzAccount @azParams
Statement : Connect-AzAccount @azParams
PositionMessage : At C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1:106
char:13
+ Connect-AzAccount @azParams
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public
PSCommandPath : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
InvocationName : Connect-AzAccount
PipelineLength : 1
PipelinePosition : 1
CommandOrigin : Internal
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot validate argument on parameter 'Tenant'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
HResult : -2146233087
CategoryInfo : InvalidData: (:) [Connect-AzAccount], ParentContainsErrorRecordException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
InvocationInfo :
MyCommand : Connect-AzAccount
ScriptLineNumber : 106
OffsetInLine : 31
HistoryId : 7
ScriptName : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
Line : Connect-AzAccount @azParams
Statement : @azParams
PositionMessage : At C:\Users\UserName\OneDrive - Crohn's and Colitis
Foundation\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1:106 char:31
+ Connect-AzAccount @azParams
+ ~~~~~~~~~
PSScriptRoot : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public
PSCommandPath : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
CommandOrigin : Internal
ScriptStackTrace : at Connect-ZtAssessment, C:\Users\UserName\OneDrive - Crohn's and Colitis
Foundation\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1: line 106
at <ScriptBlock>, <No file>: line 1
TargetSite :
Name : CheckActionPreference
DeclaringType : [System.Management.Automation.ExceptionHandlingOps]
MemberType : Method
Module : System.Management.Automation.dll
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : System.Management.Automation.ValidationMetadataException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
HResult : -2146233087
CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : ArgumentIsNull
TargetSite :
Name : Validate
DeclaringType : [System.Management.Automation.ValidateNotNullOrAttributeBase]
MemberType : Method
Module : System.Management.Automation.dll
Message : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ValidateNotNullOrAttributeBase.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : InvalidData: (:) [Connect-AzAccount], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
InvocationInfo :
MyCommand : Connect-AzAccount
ScriptLineNumber : 106
OffsetInLine : 31
HistoryId : 7
ScriptName : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
Line : Connect-AzAccount @azParams
Statement : @azParams
PositionMessage : At C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1:106
char:31
+ Connect-AzAccount @azParams
+ ~~~~~~~~~
PSScriptRoot : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public
PSCommandPath : C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1
CommandOrigin : Internal
ScriptStackTrace : at Connect-ZtAssessment, C:\Users\UserName\OneDrive - Company's Name\Documents\PowerShell\Modules\ZeroTrustAssessment\2.1.0\public\Connect-ZtAssessment.ps1: line 106
at <ScriptBlock>, <No file>: line 1Environment data
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group