0

When I try to call below power shell function from .bat file, it's not executing. Here my function needs three parameters. I tried below script from bat file.both of them didn't work. Where have I made a mistake?

powershell ".\Deploy.ps1 Install-Application -msi '.\test-1.0.1.msi'
 -InstallPath '.\InstallPath'
 -Environment 'Local'"

powershell NoProfile -ExecutionPolicy Bypass -Command  ".\Deploy.ps1 Install-Application -msi '.\test-1.0.1.msi'
 -InstallPath '.\InstallPath'
 -Environment 'Local'"


function Install-Application
{
 param(
  [Parameter(Position=0,Mandatory=$true,HelpMessage="Msi file should be existing")]
  [ValidateScript({Test-Path $_})]
  [Alias("msi")]
  [string]$File,

  [Parameter(Position=1,HelpMessage="Path wherein the resource file will be installed")]
  [Alias("path")]
  [string]$InstallPath,

  [Parameter(Position=2,Mandatory=$true,HelpMessage="Only valid parameters are Local,Dev,Test and Prod")]
  [Alias("env")]
  [ValidateSet("Local","Dev","Prod","Test")]
  [string]$Environment,

  )
0

1 Answer 1

1

Don't wrap it in a function and in your bat just use:

powershell.exe -File "c:\pathtoyourfile.ps1" -msi .\test-1.0.1.msi -installpath .\InstallPath -environment Local
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.