powershell - Trying to use $using in SetScript DSC Script Resource -


i trying use $using on setscript script resource , script failing generate mof file.

my code:

script add_admin_account         {             getscript = {                             return $null;                         }              setscript ={                             $admingrp=[adsi]"winnt://localhost/administrators,group";                             $usr=[adsi]"winnt://domain\username,user";                             $using:admingrp.add($using:usr.path)                         }             testscript = {                             $check_user_added = (net localgroup administrators | select-string "domain\username" -simplematch).tostring()                             if ($check_user_added)                              {                             write-verbose "user $check_user_added part of admin group";                             return $true; }                              else { return $false; }                          }         } 

if try use $using:admingrp.add mof gets created of no use when trying run start-dscconfiguration.

also, if try use line1 : $using:admingrp.add line2: ($using:usr.path) mof gets created has \n new line.

when use $using:admingrp.add($using:usr.path) or $using:admingrp.add() or $using:admingrp.add( fails on generate mof.

any suggestions?


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -