bibi92
asked on
'echolog' is not recognized as the name of a cmdlet if I execute the script remotely
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
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,
{
$_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
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?
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.
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.
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.
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.
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.
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.
I see the line calling echlog but not actual definition.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
Thanks, If I executed the script on host where powershell security is not remotesigned but bypass or unrestricted, it works.
Best Regards
Thanks, If I executed the script on host where powershell security is not remotesigned but bypass or unrestricted, it works.
Best Regards
Funny, both Qlemo and myself told you the same things in different words.