Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

【Az.Resources】Code signature verification fails depending on winsystemlocale #22976

Open rui-hi opened 11 months ago

rui-hi commented 11 months ago

Description

When we import Az.Resources on Windows10, 11 with ja-JP or zh-CN locale, code sign verification fails for some of the scripts. It succeed with en-EU locale so scripts itself should not be forged. Depending on the organization's compliance, the code signing verification policy may need to be "Allsigned". So could you please take a look towards this issue ?

Repro Step:

  1. Install Az.Resources module https://www.powershellgallery.com/packages/Az.Resources/6.11.1
  2. Set WinSystemLocale to ja-JP
  3. Set-ExecutionPolicy Allsigned
  4. Import-Module Az.Resources
PS C:\Users\xxxxxx> Import-Module Az.Resources
. : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..

Seems like OS level verification and Get-AuthenticodeSignature fails. image

ja-JP locale (zh-CN locale has the same problem too)

PS C:\Users\xxxx> Get-WinSystemLocale
LCID             Name             DisplayName
----             ----             -----------
1041             ja-JP            Japanese (Japan)

PS C:\Users\xxxx>  Get-AuthenticodeSignature "C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1"
Directory: C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal

SignerCertificate                         Status                                 Path
-----------------                         ------                                 ----
72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0  HashMismatch                           ProxyCmdletDefinitions.ps1

No problem with en-US locale

PS C:\Users\xxxx> Get-WinSystemLocale
LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

PS C:\Users\xxxxxxx>  Get-AuthenticodeSignature "C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1"
    Directory: C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal

SignerCertificate                         Status                                 Path
-----------------                         ------                                 ----
72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0  Valid                                 ProxyCmdletDefinitions.ps1

Issue script & Debug output

DEBUG: Initializing ConditionalAssemblyContext. PSEdition is [Desktop]. PSVersion is [5.1.20348.2031].
DEBUG: Initializing ConditionalAssemblyProvider. AssemblyRootPath is [C:\Program
Files\WindowsPowerShell\Modules\Az.Accounts\2.13.1\StartupScripts\..\lib].
. : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\Az.MSGraph.internal.psm1:34 char:91
+ ... th -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                                             ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
CmdletInvocationException: File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be loaded. The contents of file C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
   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.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At line:3 char:146
+ ... l' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [ForEach-Object], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ForEachObjectCommand
CmdletInvocationException: File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be loaded. The contents of file C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
   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.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At line:3 char:146
+ ... l' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [ForEach-Object], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ForEachObjectCommand
. : File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1
cannot be loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1 might have been changed
by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital
signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\Az.MSGraph.custom.psm1:15
char:90
+ ... ot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                                             ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
. : File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\Update-AzADUser.ps1
cannot be loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\Update-AzADUser.ps1 might have been
changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital
signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\Az.MSGraph.custom.psm1:15
char:90
+ ... ot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                                             ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
CmdletInvocationException: File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1 cannot be loaded. The contents of file C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
   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.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1 cannot be loaded. The
contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\custom\New-AzADUser.ps1 might have been changed
by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital
signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At line:3 char:144
+ ... m' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [ForEach-Object], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ForEachObjectCommand
. : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\Az.MSGraph.psm1:114 char:91
+ ... th -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                                             ~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
CmdletInvocationException: File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 cannot be loaded. The contents of file C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
   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.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At line:3 char:147
+ ... s' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [ForEach-Object], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ForEachObjectCommand
CmdletInvocationException: File C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 cannot be loaded. The contents of file C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
   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.Resources.MSGraph.Runtime.PowerShell.PsHelpers.RunScript[T](CommandInvocationIntrinsics cii, String script)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.PsHelpers.GetScriptCmdlets(PSCmdlet cmdlet, String scriptFolder)
   at Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
ForEach-Object : File C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 cannot be
loaded. The contents of file C:\Program
Files\WindowsPowerShell\Modules\Az.Resources\6.11.1\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 might have
been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the
digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing..
At line:3 char:147
+ ... s' -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [ForEach-Object], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ForEachObjectCommand

Environment data

PS C:\Users\xxxxxxx> $PSVersionTable

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

Module versions

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.11.1     Az.Resources                        {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzR...

Error output

No response

isra-fel commented 11 months ago

Thanks for reporting @rui-hi Do you mean that changing the locale after installing the module will cause it unable to be imported?

rui-hi commented 11 months ago

Hi @isra-fel Yes, but it happens regardless the locale at the time of installation. At the time of execution, or more specifically at the time of digital signature verification, system local setting should be important.

dolauli commented 11 months ago

@Nickcandy please try to reproduce this issue. Thanks.

rui-hi commented 10 months ago

Thanks, in advance. I scanned all scripts in az resources, if it has larger character code than 127. Removing specific characters from the scripts below, re-signing seemed to work.

scripts | characters 6.11.2\MSGraph.Autorest\custom\New-AzADUser.ps1 | {'–'} 6.11.2\MSGraph.Autorest\custom\Update-AzADUser.ps1 | {'’', '–'} 6.11.2\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1 | {'×', '’', '–'} 6.11.2\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1 | {'×', '’', '–'}