Problem Running Powershell Scripts With Task Sequence

Has anyone been able to use the 'Run Command Line' task sequence task and while specifying  "RUN AS" credentials  and get the script to run?

 

I have been trying to get PowerShell scripts to run from the 'Run Command Line'  task while specifying a "RUN AS" account  for a while now with no success.  Here is the syntax I use in the task sequence step: Powershell.exe -Executionpolicy Bypass -File .\filename.ps1

 

I have tried with twice now with do different scripts that work with the 'Run PowerShell Script' task, but when I use the 'Run Command Line' task the first line always throws an error.

 

For example this line: $tsenv=New-Object -COMObject Microsoft.SMS.TSEnvironment throws this error:  New-Object : The term 'New-Object' is not recognized as the name of a cmdlet, function

, script file, or operable InstallSoftware.

 

I tried another script using this method and the first line calls Get-Content which returns the error message for the cmdlet.

 

Are the know issues with running Powershell scripts using the 'Run Command Line' task and specifying a "RUN AS" account? The reason I am trying to do this in this way because I need to specify credentials, the 'Run PowerShell Script' task only runs as LocalSystem which does not have enough rights do all stuff in the script. Would anyone know what is going on here or what is causing this behavior? The script code works, it has been tested under the 'Run Powershell Script' task. The script only fails using the'Run Power Script' task due to permissions. I would appreciate any help, I just cant wrap my mind around what is happening here.

I also came across this link, can any speak on it's validity?



June 18th, 2015 7:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics