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

Unable to use Set-ObjectProperty to set Schedule on Probe #101

Closed
ninjo99 opened this issue Aug 9, 2019 · 1 comment
Closed

Unable to use Set-ObjectProperty to set Schedule on Probe #101

ninjo99 opened this issue Aug 9, 2019 · 1 comment
Labels
question Questions raised by people who don't know how to program or read the wiki :P

Comments

@ninjo99
Copy link

ninjo99 commented Aug 9, 2019

Hello,

I am trying to set schedules for remote probes but running into an issue with the API. I've tried running the below command in PowerShell which returns as successful but I don't see that the probe settings have updated accordingly.

Get-Probe -id 17834 | Set-ObjectProperty -RawParameters @{ "scheduledependency" = 0 "schedule" = Get-PrtgSchedule "7 Days a week - 7 AM - 9 AM" } -Force

I've also tried to set this without using the RawParamters method since Schedule shows as a property when queried with Get-ObjectProperty but I get the below error when I try.

Get-Probe -id 17834 | Set-ObjectProperty Schedule 4910 Set-ObjectProperty : Cannot bind parameter 'Property'. Cannot convert value "Schedule" to type "PrtgAPI.ObjectProperty". Error: "Unable to match the identifier name Schedule to a valid enumerator name. Specify one of the following enumerator names and try again: Active, InheritLocation, Location, LocationName, InheritWindowsCredentials, WindowsDomain, WindowsUserName, WindowsPassword, InheritLinuxCredentials, LinuxUserName, LinuxLoginMode, LinuxPassword, LinuxPrivateKey, WbemProtocolMode, WbemPortMode, WbemPort, SSHPort, SSHElevationMode, SSHElevationSuUser, SSHElevationSudoUser, SSHElevationPassword, SSHEngine, InheritVMwareCredentials, VMwareUserName, VMwarePassword, VMwareProtocol, VMwareSessionMode, InheritSNMPCredentials, SNMPVersion, SNMPCommunityStringV1, SNMPCommunityStringV2, SNMPv3AuthType, SNMPv3UserName, SNMPv3Password, SNMPv3EncryptionType, SNMPv3EncryptionKey, SNMPv3Context, SNMPPort, SNMPTimeout, InheritDBCredentials, DBPortMode, DBPort, DBAuthMode, DBUserName, DBPassword, DBTimeout, InheritAmazonCredentials, AmazonAccessKey, AmazonSecretKey, InheritWindowsCompatibility, WmiDataSource, WmiTimeoutMethod, WmiTimeout, InheritSNMPCompatibility, SNMPDelay, SNMPRetryMode, SNMPOverflowMode, SNMPZeroValueMode, SNMPCounterMode, SNMPRequestMode, SNMPPortNameTemplate, SNMPPortNameUpdateMode, SNMPPortIdMode, SNMPInterfaceStartIndex, SNMPInterfaceEndIndex, InheritChannelUnit, BandwidthVolumeUnit, BandwidthSpeedUnit, BandwidthTimeUnit, MemoryUsageUnit, DiskSizeUnit, FileSizeUnit, InheritAccess, Name, Tags, Priority, DebugMode, Url, HttpRequestMethod, PostData, UseCustomPostContent, PostContentType, UseSNIFromUrl, InheritProxy, ProxyAddress, ProxyPort, ProxyUser, ProxyPassword, Timeout, PingPacketSize, PingMode, PingCount, PingDelay, AutoAcknowledge, InheritInterval, Interval, IntervalErrorMode, GraphType, ExeFile, ExeParameters, SetExeEnvironmentVariables, UseWindowsAuthentication, Mutex, WmiMode, Target, PingRemotePacketSize, ChannelDefinition, FactoryErrorMode, FactoryErrorFormula, FactoryMissingDataMode, StartStopped, NotifyChanged, MonitorPerformance, Database, UseCustomInstance, InstanceName, SqlEncryptionMode, SqlServerQuery, UseSqlInputParameter, SqlInputParameter, SqlTransactionMode, SqlProcessingMode, InheritTriggers, Comments, Host, Hostv4, Hostv6, ServiceUrl, AutoDiscoveryMode, AutoDiscoverySchedule" At line:1 char:42 + Get-Probe -id 17834 | Set-ObjectProperty Schedule 4910 + ~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-ObjectProperty], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,PrtgAPI.PowerShell.Cmdlets.SetObjectProperty

I can work around this by applying the schedule at the device level if needed but was hoping to set this at the probe level. Is there any way to do this?

Thanks in advance.

@lordmilko lordmilko added the question Questions raised by people who don't know how to program or read the wiki :P label Aug 9, 2019
@lordmilko
Copy link
Owner

lordmilko commented Aug 9, 2019

Hi @ninjo99,

PrtgAPI does not currently natively support modifying settings under the Schedules, Dependencies and Maintenance Window section of PRTG as PRTG requires that all of the properties under this section be re-specified when submitting a request. If you submit a request without specifying certain properties, those properties will divert back to their default values.

This is unexpected behavior, and as such by requiring you use RawParameters in order to do this, it's not my fault if you mess up your system!

Your issue appears to be you are not using the correct raw parameters for modifying the schedule of an object. the schedule property should end in an underscore

Get-Probe -id 17834 | Set-ObjectProperty -RawParameters @{ "scheduledependency" = 0; "schedule_" = Get-PrtgSchedule "7 Days a week - 7 AM - 9 AM" } -Force

You can get a more detailed overview of the properties you can manipulate with on general objects with PrtgAPI by doing Get-Help ObjectSettings. As you will see, all of the schedule and dependency properties are listed as get-only (and in fact can only be retrieved by doing $object | Get-ObjectProperty)

Please advise if you have any further issues

Regards,
lordmilko

@lordmilko lordmilko mentioned this issue Sep 4, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions raised by people who don't know how to program or read the wiki :P
Projects
None yet
Development

No branches or pull requests

2 participants