VMware Cloud Community
fborges555
Enthusiast
Enthusiast
Jump to solution

Add AD security groups to the local administrators

HI guys

 

we I add a security group to the VM local administrators group by using powerCLI, I would like to read the VM from a list .

 

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ah, but that is different, you can't have anything on that line after @'

When you do that at the PS prompt, hit <enter> after @'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
7 Replies
fborges555
Enthusiast
Enthusiast
Jump to solution

Gurus

 

Trying to use Invoke-Vmscript and use @' '@ to create the string but it will not take  it and give the error of "No character" 

but if I use " ", it works correctly, can someone shed some light on why is that?

 

Thanks gurus

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

My crystal bol is out of service at the moment, can you show us some code to help us understand what you mean?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L

If I do the following , the invoke-vmscript works fine

$code= "
add-localgroupMember -Group 'administrators' -Member 'SG'

"

but if I do with single quote or double quote 

$code=@'
add-localgroupMember -Group 'administrators' -Member 'SG'

'@

I get the following error

"No characters are allowed after a here-string header but before the end of the line"

 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That 1st snippet is a regular string.
The 2nd snippet is a here-string, which can be done with single or double quotes.

Your here-string works perfectly for me.
Are you sure there are no (hidden) characters after @' ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L.

 

hidden characters?, there is nothing I see plain eye.

 

Thanks

Reply
0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

fborges555_0-1636555242562.png

bad format but with @'
test
'@  the red ">" still there

 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ah, but that is different, you can't have anything on that line after @'

When you do that at the PS prompt, hit <enter> after @'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos