I need to create scirpt which add users from list (containing user Display name) to group Problem I encountered is : when I issue command :
PS C:\Users\pskwarek> foreach ($a in $csv) {(get-aduser -f "DisplayName -like 'Piotr Skwarek'").samaccountname}
pskwarek
pskwarek
but if I use $a variable it doesnt work :
PS C:\Users\pskwarek> foreach ($a in $csv) {(get-aduser -f "DisplayName -like '$a.name'").samaccountname}
next step I would like to pass it to :
Add-adgroupMember -identity "groupname" -member samaccountname
but I can't make that single step
edit
PS C:\Users\pskwarek> $csv
Name
----
Piotr Skwarek
Renata Skwarek