Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing Az.DataProtection v1.0.0 in Windows PowerShell #19997

Closed
isra-fel opened this issue Nov 1, 2022 · 12 comments
Closed

Error when importing Az.DataProtection v1.0.0 in Windows PowerShell #19997

isra-fel opened this issue Nov 1, 2022 · 12 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. DataProtection Service Attention This issue is responsible by Azure service team.

Comments

@isra-fel
Copy link
Member

isra-fel commented Nov 1, 2022

Description

When I import Az.DataProtection v1.0.0 in Windows PowerShell I got the following error:

At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataP
rotectionMSIPermission.ps1:156 char:19
+                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
+                   ~
An empty pipe element is not allowed.

Issue script & Debug output

PS C:\Users\> ipmo az.dataprotection
At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
+                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
+                   ~
An empty pipe element is not allowed.
At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:180 char:15
+               | Where-Object { ($_.Scope -eq $DataSourceId -or $_.Sco ...
+               ~
An empty pipe element is not allowed.
At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:204 char:15
+               | Where-Object { ($_.Scope -eq $SnapshotResourceGroupId ...
+               ~
An empty pipe element is not allowed.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : EmptyPipeElement

CmdletInvocationException: At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
+                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
+                   ~
An empty pipe element is not allowed.

At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:180 char:15
+               | Where-Object { ($_.Scope -eq $DataSourceId -or $_.Sco ...
+               ~
An empty pipe element is not allowed.

At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:204 char:15
+               | Where-Object { ($_.Scope -eq $SnapshotResourceGroupId ...
+               ~
An empty pipe element is not allowed.
   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.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
   at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
   at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
   at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
   at System.Management.Automation.ScriptBlock.DoInvokeReturnAsIs(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
   at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(ScriptBlock sb, Boolean useNewScope, PipelineResultTypes writeToPipeline, IList input, Object[] args)
   at Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
+                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
+                   ~
An empty pipe element is not allowed.
At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:180 char:15
+               | Where-Object { ($_.Scope -eq $DataSourceId -or $_.Sco ...
+               ~
An empty pipe element is not allowed.
At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:204 char:15
+               | Where-Object { ($_.Scope -eq $SnapshotResourceGroupId ...
+               ~
An empty pipe element is not allowed.
At line:3 char:139
+ ... m' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [ForEach-Object], ParseException
    + FullyQualifiedErrorId : EmptyPipeElement,Microsoft.PowerShell.Commands.ForEachObjectCommand

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.22621.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

PS C:\Users\> gmo az*

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.10.3     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script     1.0.0      az.dataprotection                   {Backup-AzDataProtectionBackupInstanceAdhoc, Edit-AzDataProtectionPolicyRetentionRuleClientObject, Edit-AzDataProtectionPolicyTagClientObject, Edit-...

Error output

HistoryId: -1


Message        : At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
                 +                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
                 +                   ~
                 An empty pipe element is not allowed.

                 At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:180 char:15
                 +               | Where-Object { ($_.Scope -eq $DataSourceId -or $_.Sco ...
                 +               ~
                 An empty pipe element is not allowed.

                 At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:204 char:15
                 +               | Where-Object { ($_.Scope -eq $SnapshotResourceGroupId ...
                 +               ~
                 An empty pipe element is not allowed.
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.Interpreter.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                    at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine,
                 ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
                    at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
                    at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
                    at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe
                 outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
                    at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input,
                 Object scriptThis, Object[] args)
                    at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
                    at System.Management.Automation.CommandProcessor.ProcessRecord()
Exception      : System.Management.Automation.ParseException
InvocationInfo : {}
Line           :                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.Scope -eq $KeyvaultRG -or  $_.Scope -eq $KeyvaultSubscription) -and $_.RoleDefinitionName -eq $Permission}

Position       : At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
                 +                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
                 +                   ~
HistoryId      : -1

Message        : At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
                 +                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
                 +                   ~
                 An empty pipe element is not allowed.

                 At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:180 char:15
                 +               | Where-Object { ($_.Scope -eq $DataSourceId -or $_.Sco ...
                 +               ~
                 An empty pipe element is not allowed.

                 At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:204 char:15
                 +               | Where-Object { ($_.Scope -eq $SnapshotResourceGroupId ...
                 +               ~
                 An empty pipe element is not allowed.
StackTrace     :    at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
                    at System.Management.Automation.ExternalScriptInfo.ParseScriptContents(Parser parser, String fileName, String fileContents, Nullable`1 definingLanguageMode)
                    at System.Management.Automation.ExternalScriptInfo.get_ScriptBlock()
                    at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal
                 sessionState)
                    at System.Management.Automation.CommandDiscovery.CreateScriptProcessorForSingleShell(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useLocalScope, SessionStateInternal
                 sessionState)
                    at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState)
                    at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
                    at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
                    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections,
                 ExecutionContext context)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts,
                 CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParseException
InvocationInfo : {}
Line           :                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.Scope -eq $KeyvaultRG -or  $_.Scope -eq $KeyvaultSubscription) -and $_.RoleDefinitionName -eq $Permission}

Position       : At C:\Users\\Documents\WindowsPowerShell\Modules\az.dataprotection\1.0.0\custom\Cmdlets\Platform\Vault\Set-AzDataProtectionMSIPermission.ps1:156 char:19
                 +                   | Where-Object { ($_.Scope -eq $KeyVaultId -or $_.S ...
                 +                   ~
HistoryId      : -1
@isra-fel isra-fel added Service Attention This issue is responsible by Azure service team. bug This issue requires a change to an existing behavior in the product in order to be resolved. DataProtection labels Nov 1, 2022
@isra-fel
Copy link
Member Author

isra-fel commented Nov 1, 2022

@hiaga this issue should be related to this line. Removing the line-break before the pipeline operator ("|") should fix it.

@riyaz78
Copy link

riyaz78 commented Nov 7, 2022

@isra-fel @hiaga we are facing similar issue. Could you please provide any update on this bug

@sandeep10au
Copy link

@isra-fel @hiaga we are also getting this issue since last Wednesday. Any update will be much appreciated.

@eladperets
Copy link
Contributor

@hiaga @isra-fel Any ETA for a fix?

@hiaga
Copy link
Member

hiaga commented Nov 8, 2022

PR is merged for the fix - #20035

@hiaga
Copy link
Member

hiaga commented Nov 8, 2022

@isra-fel : this could be released in upcoming milestone - https://github.com/Azure/azure-powershell/milestone/136 (06/12) or earlier with an OOB release !

@CodeCyclone
Copy link

This needs to be an out of band release as it breaks environments when this module gets loaded.

@hiaga
Copy link
Member

hiaga commented Nov 8, 2022

As a workaround can use Powershell 7 (Powershell core) to import the Az module or can fallback to the previous Az module - https://www.powershellgallery.com/packages/Az/9.0.1

Steps to uninstall and install the latest module -

  1. Uninstall-Module -Name Az

  2. install-module -name Az -Repository PSGallery  -AllowClobber -RequiredVersion 9.0.1 -Force

  3. Import-module -Name Az

@hiaga
Copy link
Member

hiaga commented Nov 8, 2022

@isra-fel can we plan to fix the import command in Powershell 5 with the fix released ?

@isra-fel
Copy link
Member Author

isra-fel commented Nov 9, 2022

cc @Nickcandy we need to work on an OOB release of Az.DataProtection. @hiaga will submit the request shortly.

@hiaga
Copy link
Member

hiaga commented Nov 9, 2022

@isra-fel
Copy link
Member Author

Hi all, we have released Az.DataProtection v1.0.1 to address this issue. Please upgrade it to the latest version by

Install-Module -Name Az.DataProtection -Force

The "Az" rollup module will be updated early December.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. DataProtection Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

6 participants