fborges555
Enthusiast
Enthusiast

Add AD security groups to the local administrators

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
7 Replies
fborges555
Enthusiast
Enthusiast

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

 

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
fborges555
Enthusiast
Enthusiast

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"

 

 

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

 

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

 

Thanks

0 Kudos
fborges555
Enthusiast
Enthusiast

fborges555_0-1636555242562.png

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

 

 

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos