I'm working with Azure AD and I have imported a CSV file with some group name in it and I want to add single quote to the name properties of these group to query Azure AD but I can't seem to find any answer to my problem.
myfile.csv content:
name
Group Mémos - 1
Group Mémos - 2
I then need to add single quote to the item for when I query Azure AD
$group = import-csv c:\temp\myfile.csv
foraech ($item in $group)
{
Get-AzureADGroup -Filter "DisplayName eq $("'$item.name'")" | select ObjectId
}
My problem is the content of $item is this: '@{Name=Group Mémos - 1}.name'
but what I need is this: 'Group Mémos - 1'
How can I expand the name properties and add single quote to it?
I made a workaround by inserting the name property into another variable but I'm sure there is a way to do it that I don't understand...
$item2 = $item.Name
Get-AzureADGroup -Filter "DisplayName eq $("'$item2'")" | select ObjectId
You have misplaced the
$( )subexpression operator: