3 Replies Latest reply on May 31, 2019 3:06 PM by LucD

    Problems returning variable value

    COS Master

      My variable is called $ps-testvm_DRSAutomationLevel

      I populate it with the below....

      Set-Variable -Name $ps-testvm_DRSAutomationLevel -Value "Yomama"

      That appears to run.

       

      When I echo out the value I get this...

      PS C:\Windows\system32> $ps-testvm_DRSAutomationLevel

      At line:1 char:4

      + $ps-testvm_DRSAutomationLevel

      +    ~~~~~~~

      Unexpected token '-testvm' in expression or statement.

      At line:1 char:11

      + $ps-testvm_DRSAutomationLevel

      +           ~~~~~~~~~~~~~~~~~~~

      Unexpected token '_DRSAutomationLevel' in expression or statement.

          + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

          + FullyQualifiedErrorId : UnexpectedToken

       

      I tried escaping the - char by doing this....

      $ps-`testvm_DRSAutomationLevel

      $ps`-testvm_DRSAutomationLevel

      $ps`-`testvm_DRSAutomationLevel

       

      But no worky worky.

      I need to keep the "-" char because it is part of all the VM names.

       

      Any ideas?

       

      Thanks

      Gene Laoyan