I’ve seen various ways of running powershell scripts as part of a Task Sequence some that have worked well some not so well. The method that I have had 100% success rate with is
powershell.exe -command “set-ExecutionPolicy Unrestricted; cpi %SCRIPTROOT%\scriptname.ps1 -destination c:\; c:\scriptname.ps1; ri c:\*.ps1; set-ExecutionPolicy restricted”
This command basically drops the excution policy to unrestricted, copies the script to the local c:\, executes the script, removes the script and then sets the excution policy back to restricted.
The above assumes that you are using MDT or SCCM with MDT integrated.
If you are just using SCCM with no MDT integration, all you need to do is create a new package which contains your script and then add a step in your Task Sequence to run a command line, selecting the Package that contains your script.
Your command line should then look like:
powershell.exe -command “set-ExecutionPolicy Unrestricted; cpi scriptname.ps1 -destination c:\; c:\scriptname.ps1; ri c:\*.ps1; set-ExecutionPolicy restricted”