Powers hell script throws an error RRS feed

  • Question

  • Hi,

    We are using a power shell script in our environment that will disable expired AD account, but when I ran the scripts its throwing an error.The person who wrote the script left the organisation and I am getting below error when executing the script . The power shell version we are using is 4.0

    Can anyone give me a clue for below error ?

    At D:\SX\HR\PS\Disable-Expired-HR-ADAccounts.v1.0.ps1:191 char:17
    +                 Write-Host "$GPN: $$errorMSG"
    +                             ~~~~~
    Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to
    delimit the name.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : InvalidVariableReferenceWithDrive

    Thursday, September 20, 2018 6:43 PM


All replies

  • Remove the colon in the line.


    • Marked as answer by Shimith Thursday, September 20, 2018 6:52 PM
    Thursday, September 20, 2018 6:46 PM
  • Thanks for the help. But even that doesn't work
    Thursday, September 20, 2018 6:52 PM
  • If there is no colon how can you get the error.

    Please note that this is not a help desk or a script fixing forum.  If you do not know PowerShell then you will need to contact a consultant to fix this.


    Thursday, September 20, 2018 6:56 PM