Git Product home page Git Product logo

connectwisemanageapi's People

Contributors

amiller030 avatar bentrustack avatar brianmakes avatar christaylorcodes avatar dawsobr2 avatar ionise avatar jimhaywood90 avatar johnduprey avatar lmsjhaywood avatar nerdshade avatar teles-dwa avatar twilson-gl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectwisemanageapi's Issues

Update (or add) contact email address for a contact.

I'm using the following code to update the email address for a company contact -
`$type=@{ "value"="[email protected]";
"domain"="@company.com";
"communicationType"="Email";
"defaultFlag"="true";
"type"="";
}

$jsontype=convertto-json $type

update-cwmcontact -id 33463 -operation replace -path communicationItems -value $jsontype`

which is the closest I've got, but get
An exception has been thrown. --> Response status code does not indicate success: 400 (Bad Request). An error
| has been thrown. --> --> { "code": "InvalidPatch", "message": "Could not cast or convert from System.String
| to ConnectWise.Apis.v3_0.v2015_3.Company.Contact.ContactCommunicationItem[]." } at Invoke-CWMWebRequest,

Using 0.4.11.0

Any ideas on what I need to update here? I've removing type, default flag etc so i'm left with just the communicationType and value but still get the same error message

Unable to Update Company Configuration Question Value using Update-CWMCompanyConfigurationTypeQuestionValue

When attempting to use the Update-CWMCompanyConfigurationTypeQuestionValue function from the ConnectWiseManageAPI PowerShell module, I encountered a 404 Not Found error. The purpose was to update the answer for a specific question associated with a company configuration.

If I run the below command I get the following information:
Get-CWMCompanyConfiguration -id 28994

id: 28994
Configuration Name: FF-LGYS4-AP01

question: {@{answerId=211535; questionId=1540; question=Physical Location; answer=Test; sequenceNumber=1.00; numberOfDecimals=0; fieldType=Text; requiredFlag=False}

When I run:
$UpdateParam = @{ grandparentId = 28994 parentId = 1540 id = 211535 Operation = 'replace' Path = 'answer' Value = 'Test2' } Update-CWMCompanyConfigurationTypeQuestionValue @UpdateParam

I get the following error:

Invoke-CWMWebRequest : An exception has been thrown. --> The remote server returned an error: (404) Not Found. An error has been thrown. --> { "code": "NotFound", "message": "Configuration Type Question Value 211535 not found" }

Any guidance on how to resolve this issue or insights about the correct usage would be greatly appreciated.

Get-CWMDocument Missing recordId and recordType Parameters

Get-CWMDocument is missing recordId and recordType Cmdlet parameters as per Documents and Help markdown.

https://github.com/christaylorcodes/ConnectWiseManageAPI/blob/75ad0b72ee369a5de49f07d290c34293173f6e8c/ConnectWiseManageAPI/Public/System/Documents/Get-CWMDocument.ps1

Example workaround

$CWMAPIModule = Import-Module -Name 'ConnectWiseManageAPI' -Cmdlet @('Invoke-CWMWebRequest', 'New-CWMUrl')  -PassThru
& $CWMAPIModule {
    $Result = Invoke-CWMWebRequest -Arguments @{
        Uri = (New-CWMUrl -Endpoint "/system/documents" -URLParameters "&recordType=Ticket&recordId=1234")
        Method = 'GET'
    }
    if($Result.content){
        try{ $Result = $Result.content | ConvertFrom-Json }
        catch{
            Write-Error "There was an issue converting the results from JSON."
            $_
        }
    }
    $Result
}

Update-CWMScheduleEntry missing - trying to fix.

I noticed there was no Update-CWMScheduleEntry function and wanted to create one so that I can update my tentative schedules that were created in Outlook and synchronized over to Connectwise to Firm.
I copied the updatetemplate file over to the schedule folder, updated the endpoint and then tried to update a schedule entry with the following results

8:01:53: C:\Temp\ConnectWiseManageAPI-master\ConnectWiseManageAPI-master>  Update-CWMScheduleEntry -id 935317 -operation replace -path 'status/id' -value 2

Write-Error: C:\Temp\ConnectWiseManageAPI-master\ConnectWiseManageAPI-Master\ConnectWiseManageAPI\Private\Invoke\Invoke-CWMUpdateMaster.ps1:27

Line |
  27 |  …        $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | An exception has been thrown. --> Response status code does not indicate success: 403 (Forbidden). at
     | Invoke-CWMWebRequest,
     | C:\Temp\ConnectWiseManageAPI-master\ConnectWiseManageAPI-master\ConnectWiseManageAPI\Private\Invoke\Invoke-CWMWebRequest.ps1: line 42 at Invoke-CWMUpdateMaster, C:\Temp\ConnectWiseManageAPI-master\ConnectWiseManageAPI-master\ConnectWiseManageAPI\Private\Invoke\Invoke-CWMUpdateMaster.ps1: line 27 at Update-CWMScheduleEntry, C:\Temp\ConnectWiseManageAPI-master\ConnectWiseManageAPI-master\ConnectWiseManageAPI\Public\Schedule\ScheduleEntries\Update-CWMScheduleEntry.ps1: line 17 at <ScriptBlock>, <No file>: line 1

Any ideas why this wouldn't work - is this why there is no built in update-CWMSchedule entry (lol) ?

Also, for reference the wiki on the update template at https://github.com/christaylorcodes/ConnectWiseManageAPI/wiki/Using-a-template-to-create-Update-CWMContact uses Invoke-CWMPatchMaster -Arguments $PsBoundParameters -Endpoint $Endpoint whereas I think it should now be Invoke-CWMUpdateMaster -Arguments $PsBoundParameters -Endpoint $Endpoint

My update-CWMScheduleEntry.ps1 file looks like the following:-

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Used by sub-function')]
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    param(
        [Parameter(Mandatory = $true)]
        [int]$id,
        [Parameter(Mandatory = $true)]
        [validateset('add', 'replace', 'remove')]
        [string]$Operation,
        [Parameter(Mandatory = $true)]
        [string]$Path,
        [Parameter(Mandatory = $true)]
        $Value
    )

    $Endpoint = '/schedule/entries/$($id)'
    Invoke-CWMUpdateMaster -Arguments $PsBoundParameters -Endpoint $Endpoint
}

New-CWMCompanyContact -Type (400) Bad Request

Assuming I have a Type with id 37

$Type = @{ id = 37 }
New-CWMCompanyContact -firstName Kris -lastName Test12 -type $type

Returns Error Below:
Also, it apears there is no "Type" for Update-CWMCompanyContact

Invoke-CWMWebRequest : An exception has been thrown.
--> The remote server returned an error: (400) Bad Request.
An error has been thrown.
-->
--> {
"code": "ConnectWiseApi",
"message": "Could not find member 'type' on object of type 'Contact'. Path 'type', line 3, position 11.Check your accept header to make sure you are using the correct version.",
"errors": null
}
at Invoke-CWMWebRequest, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.7.0\Private\Invoke\Invoke-CWMWebRequest.ps1: line 41
at Invoke-CWMNewMaster, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.7.0\Private\Invoke\Invoke-CWMNewMaster.ps1: line 38
at New-CWMCompanyContact, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.7.0\Public\Company\Contacts\New-CWMCompanyContact.ps1: line 68
at , : line 1
At C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.7.0\Private\Invoke\Invoke-CWMNewMaster.ps1:38 char:19

  • ... $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments
  •                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CWMWebRequest

Additional calls

Hello

Sorry for putting into an Issue and not a PR, but needed to have a few additional calls that I dont see in the code at the moment. If you agree, can you add to you code please.

Add a configuration item to a ticket

function New-CWMTicketConfiguration {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "")]
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
    param(
    	[int]$TicketID,
        [int]$id
    )

    $URI = "https://$($script:CWMServerConnection.Server)/v4_6_release/apis/3.0/service/tickets/$TicketID/configurations"

   # Following required, as CW fails if this is passed through, ie it doesn't ignore it!
    $PSBoundParameters.Remove('TicketID')
    return Invoke-CWMNewMaster -Arguments $PsBoundParameters -URI $URI
}

Get Schedule holidays

function Get-CWMScheduleHolidayLists {
    [CmdletBinding()]
    param(
        [string]$Condition,
        [ValidatePattern('\S* (desc|asc)')]
        [string]$orderBy,
        [string]$childConditions,
        [string]$customFieldConditions,
        [int]$page,
        [int]$pageSize,
        [string[]]$fields,
        [switch]$all
    )

    $URI = "https://$($script:CWMServerConnection.Server)/v4_6_release/apis/3.0/schedule/holidaylists"
    return Invoke-CWMGetMaster -Arguments $PsBoundParameters -URI $URI
}

Get Holidays

function Get-CWMScheduleHolidays {
    [CmdletBinding()]
    param(
        [Alias('holidayListId')]
        [int]$id,    
        [string]$Condition,
        [ValidatePattern('\S* (desc|asc)')]
        [string]$orderBy,
        [string]$childConditions,
        [string]$customFieldConditions,
        [int]$page,
        [int]$pageSize,
        [string[]]$fields,
        [switch]$all
    )

    $URI = "https://$($script:CWMServerConnection.Server)/v4_6_release/apis/3.0/schedule/holidaylists/$id/holidays"
    return Invoke-CWMGetMaster -Arguments $PsBoundParameters -URI $URI
}

Get-CWMCompanyContact does not return any Company identifiers

The Get-CWMCompanyContact function does not return any Company identifiers in order to link the contact back to the company they are assigned to. The Company and Site values come back blank for every record I search, using "Get-CWMCompanyContact -Condition 'defaultPhoneNbr like "%########%"' -all". I was hoping to build a lookup for our phone system to pull the contact and company information for a customer when they call in.

Undocumented Unauthenticated Error when calling Connect-CWM

I have valid ClientID provided from the ConnectWise Developer portal and I have created a public/private key set from within the ConnectWise Manage instance for my user.

I'm assuming this is a permissions issue in the ConnectWise Manage instance against /system/info, what are the minimum Security Role permissions required to successfully login? I notice that /system/info doesn't appear to be documented under SystemSettings?

Import-Module ConnectWiseManageAPI
$CWMConnectionInfo = @{
    Server      = "connectwise.redacted.com"
    Company     = 'RedactedCompany'
    PubKey      = 'REDACTED'
    PrivateKey  = 'REDACTED'
    ClientID    = 'REDACTED'
}
$CWM = Connect-CWM @CWMConnectionInfo -Verbose -Force
VERBOSE: GET https://connectwise.redacted.com/login/companyinfo/RedactedCompany with 0-byte payload
VERBOSE: received 289-byte response of content type application/json; charset=utf-8
VERBOSE: Using API Key authentication
VERBOSE: Validating authentication
VERBOSE: GET https://connectwise.redacted.com/v4_6_release/apis/3.0/system/info with 0-byte payload
Invoke-CWMWebRequest : An exception has been thrown.
--> ConnectWiseApi
-----> ConnectWiseApi: UserNotAuthenticated
-----> ^ Error has not been documented please report. ^
at Invoke-CWMWebRequest, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.3.1\Private\Invoke\Invoke-CWMWebRequest.ps1: line 41
at Invoke-CWMGetMaster, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.3.1\Private\Invoke\Invoke-CWMGetMaster.ps1: line 45  
at Get-CWMSystemInfo, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.3.1\Public\System\Get-CWMSystemInfo.ps1: line 7        
at Connect-CWM, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.3.1\Public\Authentication\Connect-CWM.ps1: line 163
at <ScriptBlock>, REDACTED
At C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.3.1\Private\Invoke\Invoke-CWMGetMaster.ps1:45 char:19
+ ...        $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CWMWebRequest
 
WARNING: Authentication failed. Clearing connection settings.
VERBOSE: $CWMServerConnection, variable removed.

create new members via Powershell

I'm guessing this isn't a capability at this point, but is there anyway to create a new member through the API/Powershell? I'd like to implement this as part of a new user script.

Add Project Ticket

Trying to add a project ticket via PowerShell, when I use the -project with New-CWMTicket I get "New-CWMTicket : Cannot process argument transformation on parameter 'project'. Cannot convert the "386" value of type "System.Int32" to type "System.Collections.Hashtable".

Any assistance would be greatly appreciated!

Here is my code:

$CWMConnectionInfo = @{
   Server      = 'na.myconnectwise.net'
   Company     = 'BLANK'
   pubkey      = 'BLANK'
   privatekey  = 'BLANK'
   clientid    = 'BLANK'
}

# Install/Update/Load the module
if(Get-InstalledModule 'ConnectWiseManageAPI' -ErrorAction SilentlyContinue){ Update-Module 'ConnectWiseManageAPI' -Verbose }
else{ Install-Module 'ConnectWiseManageAPI' -Verbose }
Import-Module 'ConnectWiseManageAPI'

# Connect to your Manage server
Connect-CWM @CWMConnectionInfo -Force -Verbose

# Choose a company to make test a ticket for
#$Companies = Get-CWMCompany -all
#$Company = $Companies | Select-Object ID, Name | Out-GridView -OutputMode Single -Title 'Select Company'
$Company = '457'
$Project = '386'

$NewTicketParameters = @{
    summary = 'Install N-Central Agent on FWGLEX31LPTP'
    # We want to pass Manage objects as hash tables
    company           =    @{"identifier" = "$Company"}
    contactName = 'BLANK'
    contactPhoneNumber = 'BLANK'
    contactEmailAddress = 'BLANK'
   
}

$NewTicket = New-CWMTicket @NewTicketParameters -project $Project

# To clear your connection information from memory you can terminate the session or issue the disconnect command.
Disconnect-CWM

new-cwmsscheduleentry only works on service tickets and not project tickets?

Trying to create a new schedule item on a ticket to follow up in the next week or so.
Through trial and error I've almost got it working but stumped on associating the time to a ticket.

`new-cwmscheduleentry -member @{identifier='ahelsby'} -objectid 123456 -dateStart "2022-12-20T14:00:00Z" -dateEnd "2022-12-20T15:00:00Z" -status @{Name='Firm'} -reminder @{name='15 minutes'} -type @{id=1}

This gives an error of

An error has been thrown.
-->
--> {
  "code": "InvalidObject",
  "message": "schedule object is invalid",
  "errors": [
    {
      "code": "NotFound",
      "message": "Activity 123456 not found",
      "resource": "schedule",
      "field": "objectId"
    }
  ]
}

Now sure why it's trying to create an activity? I've tried against a project ticket and a service ticket to see if that makes any difference.
I've also passed the entire ticket object to the objectid parameter but that doesn't work either (unsurprisingly)

I also had to convert the start and end time to Connectwise Time and then strip off the [] otherwise I got an invalid time message.

Add Warehouse and Inventory functions

It would be good to have access to the Inventory, Stock on Hand, which requires access to Warehouses and Warehouse bins.

Examples:

Get-Warehouse
Will list all of your warehouses, standard -options apply.

Get-WarehouseBin
Will list all of your warehouse bins, standard -options apply.

Get-Inventory -parentId [WarehouseBinId]
Will list all of your inventory in the Warehouse Bin as required by the API, standard -options apply.

New-CWMTemplate not compatible with existing Invoke-CWMNewMaster function.

The current New-CWMTemplate function defines a variable $Endpoint but does not do any kind of URL joining on Line 12

Invoke-CWMNewMaster is called with an -Endpoints parameter. This is not a valid parameter for Invoke-CWMNewMaster which expects a value to be provided for -URI. This is on Line 13

The Templates should be updated to reflect how the existing Invoke functions work, or the Invoke functions should be updated to behave as intended.

Update-CWMProductCatalog recurringFlag MissingRequiredField

Hello,

I'm attempting to run:
Update-CWMProductCatalog -id $CWProductCreated.id -Operation replace -Path recurringFlag -Value True

When i run this, i get an error:

Invoke-CWMWebRequest : An exception has been thrown.
--> The remote server returned an error: (400) Bad Request.
An error has been thrown.
-->
--> {
"code": "InvalidObject",
"message": "catalogItem object is invalid",
"errors": [
{
"code": "MissingRequiredField",
"message": "recurringBillCycle or recurringOneTimeFlag is required.",
"resource": "catalogItem",
"field": "recurringOneTimeFlag"
},
{
"code": "MissingRequiredField",
"message": "recurringBillCycle or recurringOneTimeFlag is required.",
"resource": "catalogItem",
"field": "recurringBillCycle/id"
}
]
}

Running these two command together doesn't work. I feel like I need to do them both in one command?
Update-CWMProductCatalog -id $CWProductCreated.id -Operation replace -Path 'recurringBillCycle' -Value @{'id' = '2'}
Update-CWMProductCatalog -id $CWProductCreated.id -Operation replace -Path recurringFlag -Value True

Am I right in thinking they need to be run together, is that even possible? or am I doing this the complete wrong way?

Get-CWMBoardTypeSubTypeItemAssociation does not work

Hello,

I do not see the command Get-CWMBoardTypeSubTypeItemAssociation as being part of the module. This is a fresh install on Powershell 7. Perhaps I am doing something wrong?

I have the module imported, but Get-CWMBoardTypeSubTypeItemAssociation is not recognized as a valid module command.

Get-CWMDepartment and Get-CWMDepartmentLocation not available

After importing the module, these two Cmdlets seem to not be available, while all the others work. Same results when using the "-all" switch.

PS C:\Users\Administrator> Get-CWMDepartmentLocation
Get-CWMDepartmentLocation : The term 'Get-CWMDepartmentLocation' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-CWMDepartmentLocation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-CWMDepartmentLocation:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

PS C:\Users\Administrator> Get-CWMDepartment
Get-CWMDepartment : The term 'Get-CWMDepartment' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-CWMDepartment
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-CWMDepartment:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Doc Update: New-CWMCompanyTypeAssociation

The example reads:
New-CWMCompanyTypeAssociation -company @{id = 4385} -Type @{type = @{id = 68}}

In testing, it should read as:
New-CWMCompanyTypeAssociation -company @{id = 4385} -Type @{id = 68}

Get-CWMCompanyTypeAssociation not getting back full JSON payload?

https://github.com/christaylorcodes/ConnectWiseManageAPI/blob/master/Docs/Get-CWMCompanyTypeAssociation.md

This doesn't appear to return the full details from the record....

End the example below, I am not getting any of the "type" and "company" and "_info" details...
image

I was expecting something like the following from the dev site:
[ { "id": 0, "type": { "id": 0, "name": "string", "_info": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } }, "company": { "id": 0, "identifier": "string", "name": "string", "_info": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } }, "_info": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } } ]

Very likely that I am doing something wrong! :)

Error in New-CWMCompanyTypeAssociation

The Endpoint is incorrect in this function.

On line 13, it currently reads:
$Endpoint = '/companyTypeAssociations'

This should read as:
$Endpoint = '/company/companyTypeAssociations'

"String was not recognized as a valid Boolean"

Hi,

When I run this:
$companies = Get-CWMCompany -all

it starts downloading all the companies, however at the end it errors out with:

Invoke-CWMWebRequest : An exception has been thrown.
--> The remote server returned an error: (500) Internal Server Error.
An error has been thrown.
-->
--> {
"code": "ConnectWiseApi",
"message": "String was not recognized as a valid Boolean."
}
at Invoke-CWMWebRequest, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.3.3.0\Private\Invoke\Invoke-CWMWebRequest.ps1: line 41
at Invoke-CWMAllResult, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.3.3.0\Private\Invoke\Invoke-CWMAllResult.ps1: line 29
at Invoke-CWMGetMaster, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.3.3.0\Private\Invoke\Invoke-CWMGetMaster.ps1: line 44
at Get-CWMCompany, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.3.3.0\Public\Company\Companies\Get-CWMCompany.ps1: line 17
at , : line 21
At C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.3.3.0\Private\Invoke\Invoke-CWMAllResult.ps1:29 char:23

  •     $PageResult = Invoke-CWMWebRequest -Arguments $Arguments
    
  •                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CWMWebRequest

Is there anything I can do to loop through all the companies? I'm just looking for custom fields

Typo?

I think this is a small typo -
Company/CompantStatuses
should be: Company/CompanyStatuses

Aaron.

Rename ticket title?

Is it possible to rename the ticket title? Is there an API that supports this?

New-CWMTicket always returns an error about insecure redirection

I have installed the latest version of ConnectWiseManageAPI module in a Powershell 7.4 environment. I do not have any issues with most of the commands, however the New-CWMTicket command always generates the following error for me:

Line | 40 | … $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | An error has been thrown. --> --> Cannot follow an insecure redirection by default. Reissue the command specifying the -AllowInsecureRedirect switch. at | Invoke-CWMWebRequest, C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Private\Invoke\Invoke-CWMWebRequest.ps1: line 45 at Invoke-CWMNewMaster, C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Private\Invoke\Invoke-CWMNewMaster.ps1: line 40 at New-CWMTicket, | C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Public\Service\Tickets\New-CWMTicket.ps1: line 328 | at <ScriptBlock>, <No file>: line 1

I have tried:
-Closing and re-opening Visual Studio
-Disconnect / Reconnect CWM connection
-Confirmed that several of the "GET" commands work fine.

This error occurs even when using the minimum required parameters. Example:
New-CWMTicket -Summary "test" -company @{id = 19297}

Any example of updating a ticket?

Was wondering if someone had a working example to udpate a ticket. I'm not sure if the whole ticket needs to retrieved, the values change and then the whole thing replaced.

I'm currently struggling with what to put in the path/value statement.

I currently have

$a=get-cwmticket
$a.source.name
CHANGE ME

$updateparam=@{
ticketid = 1229737
Operation = 'replace'
Path = 'Source'
Value ='Phone'}
}
update-cwmticket @updateparam

But this generates the path source is not valid. I've tried changing path to source.name, Source/Name etc but obviously not getting it quite right.

Uninstalling the module generates an error - and the module does not uninstall

Great work on the module Chris.

When I issue the uninstall-module command I get the following error:

PS C:\WINDOWS\system32> uninstall-module 'connectwisemanageapi'
PackageManagement\Uninstall-Package : Access to the cloud file is denied
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.4.1\PSModule.psm1:12731 char:21

  • ... $null = PackageManagement\Uninstall-Package @PSBoundParameters
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package],
      Exception
    • FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.RemoveItemCommand,Mic
      rosoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

I have tried both 'administrative' and 'non-administrative' powershell sessions.

Pull all service ticket history attached to configurations

Hi Chris

I’m wanting to write an integration for HUDU documentation where by I display all ticket history related to a CW manage configuration,

this will be shown in html on the configuration / asset page for each configuration pulled into HUDU via their manage integration.

looking through your functions I can’t see that you pull the related ticket numbers for each configuration am I missing something or would this have to go down as a feature request.

Rhys

Bundling and Merging Tickets

Hi,

I am trying to Bundle/Un-bundle, and possibly Merge tickets automatically and I am not seeing a clear way to do this through here.

It looks like the Bundle-ing may be through this endpoint and the Child>Parent Merge operation through this endpoint

For the un-bundling (removing children) I am thinking that Update-CWMTicket might work? But perhaps not, since I can't find a field that directly lists the ChildTicket IDs

I did try this, in hopes it would be able to mimic the /service/tickets/{parentId}/attachChildren path and Add 143061 as a child to 141378

$UpdateParam = @{
    ID = 141378
    Operation = 'add'
    Path = 'attachChildren'
    Value = $("childTicketIDs=143061")
}
Update-CWMTicket @UpdateParam -verbose

But it was attempting to essentially Patch the Ticket 141378 with a node attachChildren to the value of childTicketIDs=143061
Probably roughly equivalent to this method? patchServiceTicketsById

playing with Debugging.... this seems to work, but Invoke-CWMNewMaster isn't exposed as public

$paramlist = @{ 
   childTicketIds=@(143061)
}
Invoke-CWMNewMaster -Arguments $paramlist -Endpoint '/service/tickets/141378/attachChildren'

Which works!
image

Or for invalid situations on Bundle

#Intentionally Trying to Merge a parent-with-children into a different ticket, which is invalid)

$paramlist = @{ 
    childTicketIds=@(141378)
} 
Invoke-CWMNewMaster -Arguments $paramlist -Endpoint '/service/tickets/143061/attachChildren'

it even gives helpful error messages
Success: False Message: Error absorbing Service Ticket #141368 -- This record cannot be absorbed because the supplied Parent record is a child of another Ticket.

Still trying to figure out removing children/un-bundling
Possibly set ParentID to empty/0 on Child tickets?

Get-CWMBoardTypeSubTypeItemAssociation ?

We want to obtain associated Items for a given Board Type and Board Type Subtype so we can programmatically create tickets with a populated Item field.

This would be handy to have as a Cmdlet.

An example workaround is to call the private Cmdlet Invoke-CWMGetMaster:

$CWMAPIModule = Import-Module -Name 'ConnectWiseManageAPI' -Cmdlet 'Invoke-CWMGetMaster' -PassThru
& $CWMAPIModule { Invoke-CWMGetMaster -Arguments @{Condition="subType/id = 1234"} -Endpoint '/service/boards/4321/typeSubTypeItemAssociations' }

Unable to add configuration item to a ticket.

Attempting to add a new configuration item to a ticket gives me the following error

`New-CWMTicketConfiguration -ticketId 1599150 -deviceIdentifier 18217

Invoke-CWMWebRequest : An exception has been thrown.
--> The remote server returned an error: (400) Bad Request.
An error has been thrown.
-->
--> {
"code": "InvalidObject",
"message": "configuration object is invalid",
"errors": [
{
"code": "MissingRequiredField",
"message": "id or deviceIdentifier is required.",
"resource": "configuration",
"field": "id"
}
]
}
at Invoke-CWMWebRequest, C:\Program
Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.8.0\Private\Invoke\Invoke-CWMWebRequest.ps1: line 42
at Invoke-CWMNewMaster, C:\Program
Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.8.0\Private\Invoke\Invoke-CWMNewMaster.ps1: line 38
at New-CWMTicketConfiguration, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.8.0\Public\Service\TicketConfigurations\New-CWMTicketConfiguration.ps1: line 12
at , : line 1
At C:\Program Files\WindowsPowerShell\Modules\ConnectWiseManageAPI\0.4.8.0\Private\Invoke\Invoke-CWMNewMaster.ps1:38
char:19
... $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CWMWebRequest`

I've confirmed that id 18217 is a valid id for that company, I've tried adding the configuration name in and that fails with Configuration configurationname not found.
Get-cwmticketconfiguration -ticketid 1599150 returns the other configuration items that were manually added in the gui and all the id's match

Any clues as to why it thinks deviceidentifier is required when it's included?

Error in Get-CWMCompanyTypeAssociation

Line 20 reads as:
$Endpoint = "/company/companies/$(parentId)/typeAssociations"

This was breaking. I updated in my local copy as:
$Endpoint = "/company/companies/$($parentId)/typeAssociations"

It worked after this change was made.

How to assign a resource to a ticket?

Hi,

I'm trying to figure out how to assign a resource and even though I get a HTTP 200 response using the following code below, no resources get assigned:

	$closeBody = "[{  
				op : 'add',
				path :'resources',
				value: 'xxxxxxxxx'
				}]"
					
	
				
		
				
    #Update ticket status with PATCH to OPEN first, (in case we closed it, which prevents us from adding time entries)
    try {
        $res = Invoke-RestMethod -Method Patch  -URI "$CWURL/v4_6_release/apis/3.0/service/tickets/$($ticket.objectId)" -headers $Headers -Body $closeBody -ContentType "application/json" 
    }
    catch {
        Write-Warning "Catch clause"
        Start-Sleep -Seconds 5
        $res = Invoke-RestMethod -Method Patch  -URI "$CWURL/v4_6_release/apis/3.0/service/tickets/$($ticket.objectId)" -headers $Headers -Body $closeBody -ContentType "application/json" 
    }
	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.