I have a PowerShell script in which I want to execute a function with the parameters which are provided on the commandline:
Param(
[string]$param1
[string]$param2
)
Write-Host $param1
function Run ([string]$param1, [string]$param2){
New $param1
New2 $param2
}
function New ([string]$param1){
Write-Host $param1
}
function new2 ([string]$param2){
Write-Host $param2
}
Run
But it didn't work. The Run fuction did not get the parameters from which I've provided:
./script.ps1 -$param1="hello" -$param2="hello2"
The Write-Host part outside the functions worked. But the parameters aren't passed to my Run function.
my-script.ps1 -param1 "hello" -param2 "hello2", though.