[英]'resourceGroupName' does not match expected pattern '^[-\w\._\(\)]+$'
Working with GitHub project AzViz.使用 GitHub 项目 AzViz。 I am attempting to run a PowerShell command to pull from a CSV file a list of multiple resource groups.我正在尝试运行 PowerShell 命令以从 CSV 文件中提取多个资源组的列表。 It appears to pull in the groups but errors out with the following:它似乎拉入了组,但出现以下错误:
Get-AzResourceGroup : 'resourceGroupName' does not match expected pattern '^[-\w\._\(\)]+$'.
I am creating the function here:我在这里创建 function:
$rsglist = Import-Csv C:\temp\azureinventory.csv
And running the following command:并运行以下命令:
Export-AzViz -ResourceGroup $rsglist -Theme dark -OutputFormat png -Show
You can see in this image that it is seemingly importing those resource groups:您可以在此图像中看到它似乎正在导入这些资源组:
And here is the result:结果如下:
I suspect its telling me one of the group names is wrong, but going through all of the names, I don't see any not matching that pattern;我怀疑它告诉我其中一个组名称是错误的,但是遍历所有名称,我没有看到任何不匹配该模式的名称; I don't see any characters that would not be allowed.我没有看到任何不允许的字符。
I also understand this is a project and there may be issues within their code, just looking for any assistance.我也知道这是一个项目,他们的代码中可能存在问题,只是寻求任何帮助。 Thanks!谢谢!
Export-AzViz
's -ResourceGroup
parameter expects an array of strings , whereas you're passing [pscustomobject]
instances (which turn into unhelpful string representations), as output by Import-Csv
. Export-AzViz
的-ResourceGroup
参数需要一个字符串数组,而您传递的是[pscustomobject]
实例(它变成无用的字符串表示形式),如Import-Csv
的 output 。
Use the appropriate column (property) name from your CSV file to only pass the resource-group names , as strings;使用 CSV 文件中的适当列(属性)名称,仅将资源组名称作为字符串传递; eg, if the name information is in the Name
column:例如,如果名称信息在Name
列中:
Export-AzViz -ResourceGroup $rsglist.Name -Theme dark -OutputFormat png -Show
Note: Accessing the .Name
property on the collection (array) of objects stored in $rsglist
in order to get the .Name
property values of the elements of that collection is a convenient PowerShell feature called member-access enumeration .注意:访问$rsglist
中存储的对象集合(数组)的.Name
属性以获取该集合元素的.Name
属性值是一个方便的 PowerShell 功能,称为成员访问枚举。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.