Home > Mobile >  PowerShell log output of function
PowerShell log output of function

Time:06-17

I am using dbatools to run some updates. It returns detailed results to the console. I would like to write this to a log file

  Import-DbaCsv -Path $_.FullName -SqlInstance $server -Database $DataBase -Table tempdata -schema dev -Delimiter "|"

I am using PSFramework /Write-PSFMessage but I am not sure how I can capture the output from this and log it.

CodePudding user response:

figured it out

$result =Import-DbaCsv -Path $_.FullName -SqlInstance $server -Database $DataBase -Table tempdata -schema dev -Delimiter "|"

Write-PSFMessage -Message $result

CodePudding user response:

Try with the below code.

Import-DbaCsv -Path $_.FullName -SqlInstance $server -Database $DataBase -Table tempdata -schema dev -Delimiter "|" |Out-File .\Logs.txt
  • Related