KelvinTegelaar / PowerShellWarrantyReports

a repo dedicated to automatic warranty reporting and retrieval from different systems such as IT-Glue, Connectwise, Autotask, and N-central.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set-AutotaskAPIResource.ps1 issues

latechrom opened this issue · comments

When updating AutoTask, the script is misisng -Force and adding it through the command line as described does not work with this.

The error we get when running it and the warranty field for a given ID already exists.
Cannot add a member with the name "id" because a member with that name already exists. To overwrite the member anyway, add the Force parameter to your command

Can the scripts be updated to pass along the variable or have it constantly set?

You can manually edit the scripts in the AutotaskAPI module and add the -Force flag while this is still an issue with the original repo.

Find where your Powershell modules are installed and replace line 63 in Powershell\Modules\AutotaskAPI\1.2.2\Public\Set-AutotaskAPIResource.ps1

$PSBoundParameters.body.PSObject.properties | Where-Object {$null -ne $_.Value} | ForEach-Object {Add-Member -InputObject $MyBody -NotePropertyMembers @{$_.Name=$_.Value} -Force}

Once you replace the line, make sure to re-import the module in your Powershell session with:

Remove-Module AutotaskAPI
Import-Module AutotaskAPI