-
-
Notifications
You must be signed in to change notification settings - Fork 38
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 parameter handling (in powershell) differs from documentation #264
Comments
Hi @terminatorbs, I've managed to successfully reproduce this issue In the DeviceToDestination parameter set
When parameter binding is happening however, the PowerShell engine appears to be assigning both parameters 0 and 1 to Once it becomes apparent that the parameter set is not Manual and what would normally be parameter 0 ( I'll have to figure out how I can potentially modify this cmdlet so that this works as expected without breaking of the any other parameter sets on this cmdlet |
Note that you can work around this issue for now by explicitly specifying the names of the parameters you're trying to use Get-Device -Id 45503 | Clone-Object -DestinationId 45502 -Name "ACU02" -Host "10.100.47.20" |
Thank you for the info! Yes, that's definitely a more solid solution than my workaround of adding a useless parameter, i'll adjust my script so it doesn't break when this is fixed. Also, this might not be the place for it, but thank you so much for the work you put into this. I really appreciate the thorough documentation, and this project will save me tons of work. |
@lordmilko: seems there is still another bug: PS C:\> Get-Module
Binary 0.9.17 PrtgApi {Add-Device, Add-Group, Add-NotificationTrigger, Add-Sensor...}
PS C:\> Clone-Object -SourceId $template.Id -DestinationId $destination.Id -Name $ServerHostname -Host $ServerIp
Copy-Object : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Clone-Object -SourceId $template.Id -DestinationId $destination.Id -N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Copy-Object], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmbiguousParameterSet,PrtgAPI.PowerShell.Cmdlets.CloneObject EDIT ok it works if I use the exact same form as you (piping the source). |
Hi there
I am trying to add devices in bulk, and since Clone-Device lets me add them with pre-configured sensors that's what I'm going with. I am using Powershell with the provided .bat for this.
However, whenever I attempt to clone one, the new device does not have the expected specified properties, namely Device Name and Hostname. I'm attaching a screenshot of the issue, you can see in the returned device the properties do not match what's in the command. It appears it "skips" the Name part?
From reading the documentation, it appears to me that this is supposed to work, but in my case I had to add another parameter to make it work. Here a screenshot of the command producing the expected result:
Documentation I'm referring to: https://github.com/lordmilko/PrtgAPI/wiki/Object-Creation#cloning-1
Namely the following part:
This is with the latest PrtgAPI downloaded today, against PRTG 21.3.70.1629, command run on a Windows Server 2019 build 17763
The text was updated successfully, but these errors were encountered: