I am trying to save the output file of the Start-Transcript in the cloud and exactly in shared documents. As -path string cannot be different than local on your drive I tried to define the ShareFile location(I do not want to map any drive):
Folder1 = "Shared Documents"
$SharedFolder = Get-PNPFolder -URL $Folder1
Then I tried to use it as output for a path:
Start-Transcript -path $SharedFolder
Which of course it fails. Every time it is adding in the location where the .ps1 file is a folder path like this: ps1 is in C:\aaa\ so it is adding a location like this c:\aaa\sharedfolder\transcriptfile.txt
Of course, I could use copy after and use method PNP-AddFile but there is one trick when the file is in use it doesn't want to copy it to the location which I tried to sort. I used this to copy after the Stop-Transcription
Add-PnPFile -Path ".\transcriptfile.txt" -Folder $Folder1
This command working when the script end and I run it separately after.
Maybe someone can help me differently than this?
Thank you
CodePudding user response:
So the only workaround I found is to add a Function to the .ps1 file.
I added Function with
Add-PnPFile
Which looks like this:
Function CopyFile {
Add-PnPFile -path ".\filename.txt" -folder "Shared Documents"
}
I added it before the script Exits. Don't know why standalone code won't work before.