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

bibi92
bibi92 used Ask the Experts™
on
Hello,

If I execute remotely from share a script which contain :
$SQLS='TEST'
$Db='db'
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
    if($itaas){
        Write-Host ("###LOG###;" +  $_Day + " " + $_Hour + " :: " + $_Message)
    }else{
        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

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
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 Advisor
Top Expert 2015

Commented:
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.

Commented:
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.
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
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.

Commented:
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.
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
function echolog([string]$_Message,[string]$_ForeGround)

Open in new window

starts the definition.

Author

Commented:
Hello,

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

Best Regards

Commented:
Funny, both Qlemo and myself told you the same things in different words.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial