Product: PowerShell Universal
Version: 2.5.4
I am working on uploading a file in the newer v3 dashboard directly to SharePoint. There have been a number of things resolved lately that help me move in this direction (thank you @adam for fixing the PNP.Powershell issues!), but I seem to still be missing something.
Here is my code:
New-UDForm -Id “UploadFile$InvoicesPKID” -Content {
$PMArray = $PMSQL | Sort-Object PMName
$PMArray += [pscustomobject]@{
PMName = "None"
ProjectManagementPKID = "9999999999"
}
New-UDSelect -Id "DocType" -Label "Document Type" -Option {
foreach ($type in $DLTypeSQL) {
New-UDSelectOption -Name $type.DLType -Value $type.DLType
}
}
New-UDUpload -ID "File" -Text "File"
New-UDTextBox -Id "Description" -Label "File Description"
New-UDSelect -Id "ProjectManagement" -Label "Associated Project" -Option {
foreach ($pm in $PMArray) {
New-UDSelectOption -Name $pm.PMName -Value $pm.ProjectManagementPKID
}
} -DefaultValue "9999999999"
} -OnSubmit {
$DocType = $EventData.DocType
$File = $EventData.File
$Description = $EventData.Description
$ProjectManagement = $EventData.ProjectManagement
If ($ProjectManagement -eq "9999999999") {
$ProjectManagement = $null
}
$FileName = $File.Name
Show-UDToast -Message "Filename: $FileName" -Duration 15000
Import-Module PnP.PowerShell
Connect-O365Service -SharePointPNP "https://myhost.sharepoint.com/sites/THQCentral"
$Upload = Add-PnPFile -Path $($File.Data) -Folder “Application Inventory/$DocType” -Values @{ VendorName = “$VendorName”; Description = “$Description”; Title = $($File.Name); Editor = $User; Author = $User; }
$UniqueID = $upload.UniqueId
Show-UDToast -Message "Uploaded $FileName to SharePoint library with ID of $UniqueID" -Duration 15000
}
When I do this, I get the error message “Local file was not found.”
What am I missing in this code?