I have a script (install.ps1) which uses functions from another script (Functions.ps1) using dot source. I am trying to execute the install.ps1 on a remote server using Invoke-Command. However it fails with error
The term '.\Functions.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.+ CategoryInfo : ObjectNotFound: (.\Functions.ps1:String) [], CommandNotFoundException+ FullyQualifiedErrorId : CommandNotFoundException
My install.ps1 looks like as follows:
. .\Functions.ps1 Write-Host 'Executing script remote' FunctionA "Test"
This script works fine locally, also I am able to execute the script remotely which does not use dot source. The command I am using to execute it remotely is
Invoke-Command -computername <servername> -filepath Install.ps1 -Credential $c
What are the options I have to fix this issue? Please help