The acript not work


hi ,

just 1 issue below.

write 1 function,code:

function sayhello
{
if($args.count -eq 0){"no arg"}
else {$args| foreach{"hello,$($_)"}}
}

these code work successful if run in power shell ise.

but if save ps1 file, , excute in powershell window like:

ps c:\> .\function-args.ps1

no error appear function unable used also.

plesse me issue.

cheers,

tiny

hi,

if want function available other scripts or commands within powershell, can use called dot sourcing:

ps c:\> . .\function-args.ps1

loads function memory of current powershell instance, can call it. (there blank between 2 dots)

best greetings germany
olaf






Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...