Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

calling an external function on a powershell script

Hello,

I have create this function on a ps script fc.ps1 :
function Write-EventLog
{
param([string]$msg = "Default Message", [string]$type="Information")
$log ="D:\Logs\test.log"
$time_beg=(get-date -uformat "%Y%m%d")+" "+(get-date -uformat "%H:%M:%S")
$user1=whoami
$buf=$time_beg + " par "+$user1 + ": Debut d'action => " + $msg
echo $buf |out-file $log -encoding "default" -append
}

When I try to execute this function on mains.ps1 with the command . d:\fc.ps1, no error returns but the output file isn't generated.

How can I resolve this problem?

Thanks

bibi
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial