I have a PowerShell script that contains several functions. How do I invoke a specific function from the command line?
This doesn't work:
powershell -File script.ps1 -Command My-Func
I have a PowerShell script that contains several functions. How do I invoke a specific function from the command line?
This doesn't work:
powershell -File script.ps1 -Command My-Func
This solution works with powershell core:
powershell -command "& { . .\validate.ps1; Validate-Parameters }"
If it's a .psm1 file (as opposed to .ps1) then call this instead:
powershell -command "& { Import-Module <path>\script1.psm1; My-Func }"