Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone-Object Error #309

Closed
oretom opened this issue Oct 14, 2022 · 10 comments
Closed

Clone-Object Error #309

oretom opened this issue Oct 14, 2022 · 10 comments
Labels
alleged-bug Bugs raised by people helpfully using the Bug Report template!

Comments

@oretom
Copy link

oretom commented Oct 14, 2022

Describe the bug

I have an Issue using Clone-Object:
Clone-Object : PRTG was unable to complete the request. The server responded with the following error: The object is currently not valid. Try again later.
It works for the first one or two items and then I get the error above.

Steps to reproduce

My code looks like this:
$newDevice = Get-Device -Id $SourceDevice | Clone-Object -DestinationId $GroupID

What is the output of 'Get-PrtgClient -Diagnostic'?

PSVersion      : 5.1.17763.2931
PSEdition      : Desktop
OS             : Microsoft Windows Server 2019 Datacenter
PrtgAPIVersion : 0.9.17
Culture        : de-AT
CLRVersion     : .NET Framework 4.7.2 (461814)
PrtgVersion    : 22.3.79.2108
PrtgLanguage   : english.lng

Additional context

No response

@oretom oretom added the alleged-bug Bugs raised by people helpfully using the Bug Report template! label Oct 14, 2022
@lordmilko
Copy link
Owner

Hi @oretom,

I tested against 22.3.79.2108 and was successfully able to clone a device in this way

Are you able to advise

  • How many sensors you have in your PRTG installation?
  • What the output of doing Get-Device -Id $SourceDevice | Clone-Object -DestinationId $GroupID -Verbose is?

When providing the verbose output, please obscure any sensitive details such as your company name, username and passhash

@oretom
Copy link
Author

oretom commented Oct 17, 2022

Hi

16000 active sensors.
I have added the -Verbose switch and the script ran through with no error.

regards
oretom

@lordmilko
Copy link
Owner

This indicates to me that at the time you attempted to clone the object previously, PRTG timed out. Normally PrtgAPI knows how to deal with PRTG timing out, however it sounds like PRTG timed out in a way different from normal, so I need to see the output when you specify -Verbose one time when it does time out, which unfortunately could make things a bit tricky

@mxwi
Copy link

mxwi commented Jan 11, 2023

same here:

PS C:\Users\wdx> Get-Device server1 | Clone-Object -SourceId 81082 -Resume -SkipParent -Verbose
AUSFÜHRLICH: Ausführen des Vorgangs "Copy-Object" für das Ziel "'Internet DNS' (ID: 81082), Destination: 'Server1' (ID: 77671)".
AUSFÜHRLICH: Copy-Object: Synchronously executing request https://prtg.de/api/duplicateobject.htm?id=81082&name=Internet+DNS&targetid=77671&username=aa&passhash=11
Clone-Object : PRTG was unable to complete the request. The server responded with the following error: The object is currently not valid. Try again later.
In Zeile:1 Zeichen:24
+ ... server1 | Clone-Object -SourceId 81082 -Resume -SkipParent -Verbose ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Copy-Object], PrtgRequestException
    + FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.CloneObject

the object gets cloned successfully, but paused.

edit: When I do it like this i have no problems.

foreach($dc in $DCs){

     Clone-Object -SourceId 81082 -DestinationId $dc.Id

     Sleep 20

WARNUNG: 'Copy-Object' failed to resolve object: object is still being created. Retries remaining: 4
WARNUNG: 'Copy-Object' failed to resolve object: object is still being created. Retries remaining: 3
WARNUNG: 'Copy-Object' failed to resolve object: object is still being created. Retries remaining: 2
Clone of Internet DNS        81159  EMEAADS3             Active Directory          EMEA - PRTG2          PausedByUser  
Clone of Internet DNS        81160  EMEAADS4             Active Directory          EMEA - PRTG2          PausedByUser  
Clone of Internet DNS        81161  asdfADS2            Active Directory          EMEA - PRTG2          PausedByUser  
WARNUNG: 'Copy-Object' failed to resolve object: object is still being created. Retries remaining: 4
Clone of Internet DNS        81163  EMEAADS5             Active Directory          EMEA - PRTG2          PausedByUser  

}

lordmilko added a commit that referenced this issue Jan 14, 2023
lordmilko added a commit that referenced this issue Jan 14, 2023
@lordmilko
Copy link
Owner

I have found a potential issue that may be causing this. Can you please try PrtgAPI 0.9.19-preview.1 via the Manual download instructions?

@mxwi
Copy link

mxwi commented Jan 18, 2023

Hi, looks pretty good to me.

Thanks!

@bajayb4u
Copy link

bajayb4u commented Apr 27, 2023

Hi @lordmilko, I am trying clone-object and running into same error. Where can I download PrtgAPI 0.9.19-preview.1 version from. It seems the latest build link is no longer valid.

    Clone-Object : PRTG was unable to complete the request. The server responded with the following error: The object is currently not valid. Try again later.
At line:36 char:50
+ ... rDeviceID | Clone-Object -DestinationId $destGroupID -Name $deviceNam ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Copy-Object], PrtgRequestException
    + FullyQualifiedErrorId : PrtgRequestException,PrtgAPI.PowerShell.Cmdlets.CloneObject

Thank you!

@squintfox
Copy link

I had this same problem and using the latest build version solved it for me as well.

@Maxell0089
Copy link

Hi have the same error :

VERBOSE: Performing the operation "Copy-Object" on target "'Template Serveur [Windows]' (ID: 45327), Destination: 36316". VERBOSE: Copy-Object: Synchronously executing request https:///api/duplicateobject.htm?id=45327&name=csvr-app01w-3&targetid=36316&host=csvr-app01w-3&username=PRTGApiCall&passhash=***

Clone-Object : PRTG was unable to complete the request. The server responded with the following error: The object is currently not valid. Try again later. At Clone_device.ps1:100 char:41 + ... -Id 45327 | Clone-Object -DestinationId $GroupeID -host $DeviceHost ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ModuleType Version Name ExportedCommands


Binary 0.9.18 PrtgAPI {Get-Channel, Get-Device, Get-DeviceTemplate, Get-Group...}

@lordmilko
Copy link
Owner

Hi @Maxell0089,

Can you try with the latest build?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alleged-bug Bugs raised by people helpfully using the Bug Report template!
Projects
None yet
Development

No branches or pull requests

6 participants