Automation

 View Only
  • 1.  Add AD security groups to the local administrators

    Posted Nov 09, 2021 09:18 PM

    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



  • 2.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 01:09 AM

    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

     



  • 3.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 06:19 AM

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



  • 4.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 12:33 PM

    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"

     

     



  • 5.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 01:39 PM

    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 @' ?



  • 6.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 02:40 PM

    L.

     

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

     

    Thanks



  • 7.  RE: Add AD security groups to the local administrators

    Posted Nov 10, 2021 02:42 PM

    fborges555_0-1636555242562.png

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

     

     



  • 8.  RE: Add AD security groups to the local administrators
    Best Answer

    Posted Nov 10, 2021 02:43 PM
      |   view attached

    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 @'