Closed mafer0410 closed 3 years ago
I have tried to do the following:
where {[string] $ . datetime.hour + [string] ":" + [string] $ . datetime.minutes -le [string] $ output -and [string] $ . datetime.hour + [string] ": "+ [string] $ . datetime.minutes -ge [string] $ input}
but it does not validate the time with its minutes so far.
Hi @mafer0410,
This question appears to be more to do with how to manipulate times in PowerShell rather than PrtgAPI
To get a specific time today you can do (Get-Date).Date.AddHours(7).AddMinutes(15)
for 7:15am; you can then do a similar thing to get a different time to compare for.
PrtgAPI provides a PowerShell framework for interfacing with PRTG, however you will need to apply additional general purpose PowerShell knowledge in order to effectively write scripts that achieve specific functionality. Unless a question is specific to PrtgAPI, you should be able to get good search results by Googling "how to do x in PowerShell", "how to do x in C#" or "how to do x in .NET" and you should find the information you need. As PowerShell is built on top of the .NET Framework, you can apply all the information that applies to .NET and C# to PowerSell as well.
Yes, I've been reading and researching, it still hasn't worked.
I have used the option: $ _. Datetime.minute but it is not recognized.
El mié, 2 de dic. de 2020 a la(s) 17:10, lordmilko (notifications@github.com) escribió:
Hi @mafer0410 https://github.com/mafer0410,
This question appears to be more to do with how to manipulate times in PowerShell rather than PrtgAPI
To get a specific time today you can do (Get-Date).Date.AddHours(7).AddMinutes(15) for 7:15am; you can then do a similar thing to get a different time to compare for.
PrtgAPI provides a PowerShell framework for interfacing with PRTG, however you will need to apply additional general purpose PowerShell knowledge in order to effectively write scripts that achieve specific functionality. Unless a question is specific to PrtgAPI, you should be able to get good search results by Googling "how to do x in PowerShell", "how to do x in C#" or "how to do x in .NET" and you should find the information you need
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lordmilko/PrtgAPI/issues/187#issuecomment-737551318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGVFY7MHLYLLJOK6AAYTH3SS3CQHANCNFSM4ULCWZDQ .
Hi, I have the following validation:
If you do not want to include weekends and with defined hours
if (($ fin -match 'N') -and ($ hours -match 'B')) {
Average of all channels of the sum of the values of the X days
$ value_pr = Get-device -Id $ CharArray [$ i] | Get-sensor -Type $ type | Get-SensorHistory -end (get-date) .adddays (- $ days) .Date -start (get-date) -Average $ finaltime | where {$ . datetime.DayOfWeek -ne "Sunday" -and $ _. datetime.DayOfWeek -ne "Saturday"} | Format-Table -AutoSize | Out-String
Shows all the history of the channels where the final average was obtained
$ all = Get-device -Id $ CharArray [$ i] | Get-sensor -Type $ type | Get-SensorHistory -end (get-date) .adddays (- $ days) .Date -start (get-date) -Average $ timesec | where {$ . datetime.hour -ge $ input -and $ . datetime.hour -le $ output -and $ . datetime.DayOfWeek -ne "Sunday" -and $ _. datetime.DayOfWeek -ne "Saturday" } | Format-Table -AutoSize | Out-String
}
I have the validation of the hours, but I would like it to validate times like 7:15 or 15:20. For this, which option is best used for the API: validate the hour and minute separately, or validate everything together?