简体   繁体   中英

'resourceGroupName' does not match expected pattern '^[-\w\._\(\)]+$'

Working with GitHub project AzViz. I am attempting to run a PowerShell command to pull from a CSV file a list of multiple resource groups. 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:

$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 .

Use the appropriate column (property) name from your CSV file to only pass the resource-group names , as strings; eg, if the name information is in the Name column:

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM