Forum Discussion
Gary Schultz
May 04, 2018Iron Contributor
Re: PnP PowerShell - tell if an Add-PnPFile was successful
The following works for me
$FileSuccessLog = "C:\temp\logging\FileSuccessLog.log"
$FileFailureLog = "C:\temp\logging\FileFailureLog.log"
Try{
Add-PNPFile -Path $FilePath -folder "Some Document Library/Folder"
$fileSuccess = "Y"
}
Catch{
$fileSuccess = "N"
}
Finally {
Switch($fileSuccess){
N{
Add-content $FileFailureLog -value "$(get-date -f o) Failure with attempt to add file $FilePath."
}
Y{
Add-content $FileSuccessLog -value "$(get-date -f o) Success with attempt to add file $FilePath."
}
}
}
No RepliesBe the first to reply