admin管理员组文章数量:1278854
I've got a script that adds a file then reads an excel sheet and then populate a sharepoint document library with that data. The command looks something like
Add-PnPFile -Path $Path -Folder $LibraryName -Values @{"Name" = $Values[0]; "Classification" = $Values[1]; "DocumentID" = $Values[2]; "EffectiveDate" = $Values[3]; "DatePublished" = $Values[4]; "EndDate" = $Values[5]; "RNumber" = $Values[6]}
Everything works fine until one of the date columns needs to be a blank and it's value in the array is blank. Whenever that happens i notice that even though the document gets populated, all the columns are blank. What values can be passed instead of an empty string for the datetimes for this to work?
Edit: do want to add that whenever i replace the blank with a dummy date, it works just fine
I've got a script that adds a file then reads an excel sheet and then populate a sharepoint document library with that data. The command looks something like
Add-PnPFile -Path $Path -Folder $LibraryName -Values @{"Name" = $Values[0]; "Classification" = $Values[1]; "DocumentID" = $Values[2]; "EffectiveDate" = $Values[3]; "DatePublished" = $Values[4]; "EndDate" = $Values[5]; "RNumber" = $Values[6]}
Everything works fine until one of the date columns needs to be a blank and it's value in the array is blank. Whenever that happens i notice that even though the document gets populated, all the columns are blank. What values can be passed instead of an empty string for the datetimes for this to work?
Edit: do want to add that whenever i replace the blank with a dummy date, it works just fine
Share Improve this question edited Feb 24 at 22:19 DanielJ asked Feb 24 at 21:32 DanielJDanielJ 1091 gold badge4 silver badges14 bronze badges 4 |1 Answer
Reset to default 1Ended up creating a hashtable and only passing in the Key/Value if they had data
# Initialize an empty hashtable
$HashTable = @{}
# Split into key-value pairs safely
$Values -split ";" | ForEach-Object {
if ($_ -match "=") { # Ensure the pair contains '='
$Key, $Value = $_ -split "=", 2 # Split into two parts only
$Key = $Key.Trim()
$Value = $Value.Trim()
# Ensure both key and value are valid before adding to hashtable
if ($Key -ne "" -and $null -ne $Value) {
$HashTable[$Key] = $Value
}
}
}
# Debug output
$HashTable | Format-Table -AutoSize
Add-PnPFile -Path $Path -Folder $LibraryName -Values $HashTable
本文标签:
版权声明:本文标题:windows - Trying to add files to a sharepoint library via Add-PnPFile but whenever a blank value is sent to a datetime column, n 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741240943a2363964.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
''
) or$null
? – mklement0 Commented Feb 24 at 22:14