Skip to content
English
  • There are no suggestions because the search field is empty.

Export-Document fails with "Cannot bind parameter 'Options' to the target"

Description

When the result of Join-Path is used in the Export-Document -Options parameter then Export-Document will fail with "Cannot bind parameter 'Options' to the target"

The log file contains something like

2026-03-04 14:17:25,199 [PSES Pipeline Execution Thread] WARN  powerJobs.Cmdlets.CmdLets.ExportDocument - ExportDocument.set_Options({C:\ProgramData\coolOrange\powerJobs\Modules\Export\PDF_2D.ini}) | Failed: exception = {coolOrange.Powershell.Cmdlets.PsInvalidArgumentException}.
coolOrange.Powershell.Cmdlets.PsInvalidArgumentException: Invalid Type! Only following argument types are supported: System.Collections.Hashtable ,System.Management.Automation.PSObject
   at coolOrange.Powershell.Cmdlets.PsPropertiesArgument. (Object ?)
   at coolOrange.Powershell.Cmdlets.PsPropertiesArgument..ctor(Object properties)
   at powerJobs.Cmdlets.CmdLets.ExportDocument.set_Options(Object value)

Cause

This happens because the Export-Document -Options parameter only accepts string or Hashtable objects. In older versions there was error handling when incorrect parameters were passed in.

Solution

If you have something like this

Open-Document -LocalFile "C:\temp\Drawing1.idw" -Application Inventor
$joinPathResult = Join-Path -Path 'C:\ProgramData\coolOrange\powerJobs\Modules\Export' -ChildPath 'PDF_2D.ini'
$exportResult = Export-Document -To "C:\TEMP\Circle.idw.pdf" -Format PDF -Options $joinPathResult

just cast the result to string before passing it into the Export-Document cmdlet.

Open-Document -LocalFile "C:\temp\Drawing1.idw" -Application Inventor
$joinPathResult = Join-Path -Path 'C:\ProgramData\coolOrange\powerJobs\Modules\Export' -ChildPath 'PDF_2D.ini'
$exportResult = Export-Document -To "C:\TEMP\Circle.idw.pdf" -Format PDF -Options ($joinPathResult.ToString())