Reputation:
Trying to write a simple PowerShell script, but got stuck with an error, and I can't find any solution on the web.
$stream = [IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes('aaaaaaaaaa!'))
Get-FileHash -InputStream $stream -Algorithm SHA512
AddPnPFile -Path './bundle.json' -Folder "$($FolderRelativeURLGeneral)$($folder)" -Stream $stream
Why am I getting an error for providing a stream to the Stream parameter? Removing the parameter solved the issue, but obviously I want to write something to the file, so can someone tell me how to write content to the file? Do I need to create a filestream out of the stream? However, the documentation doesn't specify that it has to be a file stream. How come it doesn't work?
How to convert a string to a stream object in Powershell?
Upvotes: 0
Views: 3558
Reputation: 10019
In PowerShell, a parameter set specifies which parameters can be used together when calling a function.
You can use parameters from one set or another set, you cannot mix and match.
Checking the documentation for Add-PnPFile
, Path
and Folder
are part of one parameter set, while Folder
and Stream
are part of another; there is no parameter set that has all 3 parameters.
I think you're looking for FileName
(which i assume creates a file from the stream) instead of Path
(which is a local file path).
Upvotes: 1