This is just additional info to answers in order to pass argument into the another file
Where you expect argument
PrintName.ps1
Param(
[Parameter( Mandatory = $true)]
$printName = "Joe"
)
Write-Host $printName
How to call the file
Param(
[Parameter( Mandatory = $false)]
$name = "Joe"
)
& ((Split-Path $MyInvocation.InvocationName) + "\PrintName.ps1") -printName $name
If you do not do not provide any input it will default to "Joe" and this will be passed as argument into printName argument in PrintName.ps1 file which will in turn print out the "Joe" string