Hi, I'm developing a script to migrate our eDOCS DM data to Content Server. Everything is pretty much done and I've been able to migrate about 200K documents in a test run. I've ran into some issues that I'd like to fix.
I have the following snippet of code:
function New-CSDocument {
param($CsUrl, $OtcsTicket, $ParentID, $ProfileData, $FullDocumentPath, $TypeId)
$Header = @{
"OTCSTicket" = $OtcsTicket
"Accept" = "*/*"
"accept-encoding" = "gzip, deflate"
"Cache-Control" = "no-cache"
}
$OTCSUploadForm = @{
file = (Get-Item -Path $FullDocumentPath)
type = $TypeId
parent_id = $ParentID
description = $ProfileData.ABSTRACT
name = ($ProfileData.DOCNAME).Replace(":","") # Remove unsupported character from document name.
external_create_date = ($ProfileData.DOCDATE).ToString("yyyy-MM-dd HH:mm:ss")
external_modify_date = ($ProfileData.LASTEDITDATE).ToString("yyyy-MM-dd HH:mm:ss")
external_identity = $ProfileData.AUTHOR_ID
external_identity_type = "generic_userid"
external_source = "edocs"
}
try{
$NewNodeId = Invoke-RestMethod -Method Post -Uri "$CsUrl/otcs/cs.exe/api/v1/nodes" -Form $OTCSUploadForm -Headers $Header -ContentType "multipart/form-data" | Select -ExpandProperty Id
return @{"result" = "success"; "data" = $NewNodeId}
}catch{
$errorData = $_
return @{"result" = "failure"; "data" = $_}
}
}
Where $ProfileData is the profile data from a DM document and $FullDocumentPath is the actual path of the document stored in the DM file server. As some of you may know, DM stores files with random names and these can contain exclamation marks (!). I believe that my upload function predominantly fails trying to upload documents that have a ! in their file name. What could I do to fix this issue?