How To Solve the PowerShell Error “The term ‘script’ is not recognized…”

Goal:  You want to run a .ps1 file.
Problem:  You get the error "Powershell : script : The term 'script' is not recognized as the name of a cmdlet, At line:1 char:1 + ..."
Solution:  Use the "script" resource section inside of a DSC configuration exclusively.  It will not work or run as a standalone PowerShell script.  Scripts with GetScript, SetScript, and TestScript must be run as part of a DSC configuration.  Also, DSC must be installed for configurations to work.  The "script" block should appear under the "configuration nameOfConfiguration" {} section of the .ps1 file.

Leave a comment

Your email address will not be published. Required fields are marked *