简体   繁体   中英

Write PnP PowerShell log file

I have a PnP PowerShell script for which log file has to be written with some specific details in Excel file

I have tried some simple ways like start-transcript but didn't work

You can use Export-CSV function to write to CSV/Excel file. First create a variable and then write your logs to the variable finally export it to CSV. See example below:

$logData = @()
$logData += New-Object PSObject -Property ([ordered]@{
"DateTime" = $someDateValue
"Message" = $logMessage
})
$logData | Export-Csv -NoTypeInformation "c:\temp\log.csv"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM