Using Powershell as deployment script gives error: The specified executable is not a valid application for this OS platform.


  • Hi,

    I have set up a Lab Environment using the LabDefaultTemplate.

    I have created a Powershell script as a deployment script. When the Deployment Script are being run on my lab machine i recieve the following error "The specified executable is not a valid application for this OS platform."

    It doesn't matter if use a empty ps1 file or a file that contains my deployment script. The powershell executing policy on the Lab Server is set to "Unrestricted".

    Below is extract from the logfile.

    Running Deployment Script
    Initial Property Values
    MaximumAttemptsForNetUse = 0
    ScriptDetails = Virtual machine:  SharePoint 2010 AgentSpec:  Name=*, Tags=MachineName=SharePoint 2010,EnvironmentName=SharePoint 2010,TeamProject=Team Project 1,TeamProjectHostGroup=All Hosts FileName:  \\testtfs2010bld1.MyDomain.local\drop\Build all wsp\Build all wsp_20101128.7\Deploy.ps1 Arguments:   WorkingDirectory: c:\temp EnvironmentVariables: BuildLocation=\\testtfs2010bld1.MyDomain.local\drop\Build all wsp\Build all wsp_20101128.7 InternalComputerName_Domain Controller=WIN-U80J27DQQQN ComputerName_SharePoint 2010=VSLM-232-d9d724c4-8069-4626-8ac5-94adc974b950.MyDomain.local InternalComputerName_SharePoint 2010=WIN-92B3JTMC66T
    SharedLocationForNetUse = \\testtfs2010bld1.MyDomain.local\drop\Build all wsp\Build all wsp_20101128.7
    ThrowOnError = True

    Running Script on virtual machine SharePoint 2010:
    Accessing the following location using the lab service account: MyDomain\svcTFSlabservice, \\testtfs2010bld1.MyDomain.local\drop.
    \\testtfs2010bld1.MyDomain.local\drop\Build all wsp\Build all wsp_20101128.7\Deploy.ps1

     The specified executable is not a valid application for this OS platform.

    Stopped accessing the following location using the lab service account: MyDomain\svcTFSlabservice, \\testtfs2010bld1.MyDomain.local\drop.

    All servers are x64 including lab servers, TFS roles and the dev environment.

    Any idea how to troubleshoot this?


    • Edited by Tony Fabian Sunday, November 28, 2010 5:35 PM clarification
    Sunday, November 28, 2010 5:32 PM

All replies

  • Hi Tony,

    I think the issue here is that calling the ps1 script does not automatically launch the PS shell. You will need to explicitly launch the shell and run the file within it. You can invoke this script by calling

    powershell.exe -file \\yourpath\your.ps1

    which is what would need to be specified as your deployment script parameter as well.




    Tuesday, November 30, 2010 8:57 AM
  • Hi Tony

    I hope you are able to proceed with the solution suggested by Allen. Let us know if you have any additional questions.


    Hariveer Singh | If a post appropriately answers your query, Click 'Mark as Answer'.
    Wednesday, December 22, 2010 6:48 PM
  • I'm having the same problem.  How exactly should I have this configured in my build template.  I am using the RemoteExecute activity with Team Deploy 2010 in TFS 2010 with the following configuration:

    DisplayName:  RemoteExecute

    IgnoreExitCode: (blank)

    OptionalParameters: (blank)

    RemoteCommand: "powershell.exe"

    RemoteExecutePathFilename: "C:\Scripts\Deploy.ps1"

    TargetMachine: "ServerName"

    WaitForExit: (blank)


    Thursday, April 28, 2011 6:53 PM
  • Hi BuildDude,

    I havent used TeamDeploy myself but this is what I picked up from the documentation

    RemoteExecute TargetMachine Name of target machine
      RemoteCommand Command to execute on target machine
      RemoteExecutePathFilename Path and filename of PsExec.exe
      OptionalParameters Optional arguments for the command
      WaitForExit Flag to specify to wait for process to complete


    So you would need to have your parameters modified to

    RemoteCommand: "powershell.exe"

    OptionalParameters: "-file C:\scripts\deploy.ps1"

    RemoteExecutePathFileName: "C:\sysinternals\psexec.exe"




    Allen Mathias



    Tuesday, May 03, 2011 4:56 AM
  • Hi,

    I am stuck in a similar issue. I am adding  a invokeprocess activity in TFS build process template to send an email with the test results.

    in the FileName property of the activity, i am giving \\<servername>\SendTestResultsEmail.ps1 .


    It is failing with the error: "The specified executable is not a valid application for this OS platform"

    did you mean that i should give "powershell.exe -file \\yourpath\your.ps1" in File Name property? it doesn't work because it's looking for the file name in this property.


    I even tried giving "C:\Windows\System32\WindowsPowerShell\v1.0" in working directory of activity but no luck, I get the same error.


    Any idea on troubleshooting this?


    Deepika Arora
    Friday, May 27, 2011 11:47 PM
  • Hi,

    For a powershell script in the Team Build InvokeProcess activity you should specify

    a) the filename as the full path to the poweshell.exe and

    b) then specify the arguments as "-filename <your.psscript.ps1>"


    Allen Mathias

    Saturday, May 28, 2011 5:12 AM
  • Hi BuildDude,

    I hope the suggested changes have worked for you.


    Tuesday, May 31, 2011 1:27 PM
  • Hi Deepika,

    Did the changes unblock you?

    Tuesday, May 31, 2011 1:27 PM
  • thanks Allen,

    I didn't try from build process template but i did try the whole command thru powershell cmd prompt. it seems that the -filename parameter is not getting recognized. i tried following command and got error that "The term '-filename' is not recognized as the name of a cmdlet".

    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -filename "<servername>l\SendTestResultsEmail.ps1"  <arguments to script>


    I tried without the -filename attribute i.e.

    a) Filename =  C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe

    b)  Arguments = String.Format(" ""& '{0}' '{1}' "" ", <powershell scriptfile>,<arguments to powershell script>)

    this line doesn't fail with any error, i see the following in the build log but i never got an email.

    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe  "&'<powershell scriptfile>' "  <arguments to powershell script>


    when i just copy and paste this line from build log on a cmd prompt and run, i do get an email. (i am passing my email address in arguments of script).

    i have no idea what's going wrong.




    Deepika Arora
    Tuesday, May 31, 2011 4:58 PM
  • Hi Allen,


    I even tried with -File parameter i.e.

            a. Filename =  C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe

            b. Arguments = -File "<powershell scriptfile>" "<arguments to powershell script>"

    again, i don't see anything failing , I see the following in the build log but i never got an email.

    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -File  <powershell scriptfile>  <arguments to powershell script>


    If i try to execute the same line from my machine's powershell cmd prompt, it works good and i do get an email.


    appreciate your help here.



    Deepika Arora
    Wednesday, June 01, 2011 1:08 AM
  • One gotcha is Powershell Execution policy: by default it forbids executing scripts residing on a network share. You can add the -ExecutionPolicy argument with a value like Unrestricted to verify if this is the cause.
    Wednesday, June 22, 2011 10:35 AM