Using Powershell 3.0/4.0 commands? ie Invoke-WebRequest

Dec 20, 2013 at 10:59 PM
I'm pretty happy with TFS Deployer but one thing I can't seem to get to work is get it to use the Invoke-WebRequest command in the powershell script.

I get this following error:
Output:
Invoke-WebRequest : The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


I might be wrong but I think this error is happening because, PowerShell 2.0 was installed on the machine, but now I've upgrade the machine to 4.0, and when I open Powershell on the machine I can manually use the Invoke-WebRequest command, however, I still get the same error with TFS Deployer.

Is there a setting somewhere in TFS Deployer which specifies something like which powershell version to use that I can change? Or is there any other reason this would happen?

Thanks
Jan 15, 2014 at 5:43 PM
still hoping for an answer to this, not sure if anyone is looking
Coordinator
Jan 15, 2014 at 8:50 PM
Hi,

In the latest release of TFS Deployer, the DeploymentMappings.xml supports a "PowerShellV3" value for the RunnerType attribute on the Mapping element. You can see an example at the bottom of the sample file here:

https://tfsdeployer.codeplex.com/SourceControl/latest#Trunk/TfsDeployer/TfsDeployer/Samples/DeploymentMappings.xml

If this RunnerType attribute is missing or is set to a value of just "PowerShell" then the out-of-process deploy agent will run under .NET 3.5/CLR 2.0 which will then use PowerShell 2.0 or, if a later version of PowerShell is installed, it will use the PowerShell 2.0 compatibility-mode.

When the RunnerType attribute is set to the value "PowerShellV3" then the out-of-process deploy agent will run under .NET 4.x/CLR 4.0 which will then use PowerShell 3.0 or 4.0, whichever is present. (If only PowerShell 2.0 is present, it will still execute under .NET 4 which will give scripts access to newer .NET Assemblies but this is somewhat unsupported by Microsoft and many third party PowerShell modules).

Personally I would normally prefer if TFS Deployer defaulted to the latest version of PowerShell installed by default but at the time this functionality was added to TFS Deployer, PSv3 was still in Beta, and I figured most existing users would rather opt-in for changes that might impact their deployments.

Regards,

Jason
Jan 15, 2014 at 9:41 PM
Hi!

Thanks so much , this worked perfectly, and I knew it must be something obvious like that!


Thanks
Rob