1

I am new to Powershell and having trouble calling a function contained within a script file.

Can anyone tell me how to do this please.

I have a function defined as follows:

    function Install-BizTalkApplicationTest
{

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

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

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

  [bool]$BTDeployMgmtDB=$true,
  [bool]$SkipUndeploy=$true
  )

  Write-Host "param MsiFile = {0}" -f $MsiFile

 }

This function is contained in a file called TestScript.ps1

I open a Powershell command window and enter .\Testscript1.ps1. I don't get any feedback, just taken to the next PS> line.

So I try to execute by entering the function name Install-BizTalkApplicationTest. I then get the error "The term '.\Install-BizTalkApplicationTest' is not recognized as the name of a cmdlet, function, sxript file, or operable program"

Could anyone please advise how to call a function (with params) that is contained within a script file?

Thanks, Rob.

1

1 Answer 1

2

To load a script file, you have to prepend with a .. So, in full, . .\Testscript1.ps1.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.