Open terminatorbs opened 2 years ago
Hi @terminatorbs,
I've managed to successfully reproduce this issue
In the DeviceToDestination parameter set
-DestinationId
is positionally parameter 0,-Name
is parameter 1-Host
is parameter 2When parameter binding is happening however, the PowerShell engine appears to be assigning both parameters 0 and 1 to -Name
(-Name
is parameter 0 in the Manual parameter set).
Once it becomes apparent that the parameter set is not Manual and what would normally be parameter 0 (-DestinationId
) was specified as a named parameter, you would expect the PowerShell engine would figure out that the the remaining parameters 0 and 1 now map to 1 and 2 (-Name
and -Host
), however that is clearly not what is happening.
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