'echolog' is not recognized as the name of a cmdlet if I execute the script remotely


If I execute remotely from share a script which contain :
echolog : The term 'echolog' 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.
function echolog([string]$_Message,[string]$_ForeGround)
    $_Day=Get-Date -f yyyy/MM/dd
    $_Hour=Get-Date -f  HH:mm:ss
        Write-Host ("###LOG###;" +  $_Day + " " + $_Hour + " :: " + $_Message)
        Write-Host "$_ScriptName - $_Day $_Hour :: LOG :: $_Message";
    $_ScriptName + " - " + $_Day + " " + $_Hour + " :: LOG :: " + $_Message | Out-File $_LogFile -append;

echolog("Create database $Db (SQLServer : $SQLS)")

The following error is returned but not if I execute the script locally, why ?
'echolog' is not recognized as the name of a cmdlet

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ben HartCommented:
Maybe 'echolog' is not a defined cmdlet on the remote system?  I do not believe echolog is a native posh cmdlet as I can't find anything about it.  Or is it part of some weird snapin module? Can you paste the actual code?
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Please repost, and clearly separate script and output. Above you mixed them into the comment in an impossible sequence.
But as much as I can see, echolog needs to be defined before it is used. Probably you have done that locally, e. g.  by executing another script.
Ben HartCommented:
Even if you ignore lines 4, 5, 6 above.. it clearly looks like echlog is a custom cmdlet that is not defined.. the remote system knows nothing about it.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Ben, if you look further down you'll see the definition of that function. And where do you start to count?
More, this is another of endless attempts to get bibi92 to post in a way we can do something for her. As-is, we have to assume, and that is very very bad.
Ben HartCommented:
Ahh there history with bibi, makes sense now.  I counted from the line beginning with 'if'.

I see the line calling echlog but not actual definition.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
function echolog([string]$_Message,[string]$_ForeGround)

Open in new window

starts the definition.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bibi92Author Commented:

Thanks, If I executed the script on host where powershell security is not remotesigned but bypass or unrestricted, it works.

Best Regards
Ben HartCommented:
Funny, both Qlemo and myself told you the same things in different words.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.