AndrewG-1234 / PRTG

13 stars 7 forks source link

Set-PRTGPauseThisServer fails #2

Open mozzis opened 7 years ago

mozzis commented 7 years ago

Invoked with: Set-PRTGPauseThisServer -Minutes 1440 -Message "Shutting down..." Errors seen:

Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named "op_Addition" At \\server1\users\scripts\PRTG\PRTG.psm1:573 char:5 + $myips += $t + ~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named :op_Addition". At \\server1\users\scripts\PRTG\PRTG.psm1:577 char:5 + $myips += $t + ~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound

mozzis commented 7 years ago

I fixed this locally by changing the line $myIPs = Get-NetIPAddress -AddressFamily IPv4 | where { $_.InterfaceAlias -notmatch 'Loopback'} | Select IPAddress to read $myIPs = @(Get-NetIPAddress -AddressFamily IPv4 | where { $_.InterfaceAlias -notmatch 'Loopback'} | Select IPAddress)

mozzis commented 7 years ago

But now I can see that it still fails to get any values for $myIPs when it is running during the actual PC shutdown. I can run it interactively (including from the machine SYSTEM account) and it works fine, but somehow when it is run by the system during shutdown, the line $myIPs = @(Get-NetIPAddress -AddressFamily IPv4 | where { $_.InterfaceAlias -notmatch 'Loopback'} |Select IPAddress) returns an empty array. I verified this using logging statements in the function.

r-ramsay commented 5 years ago

But now I can see that it still fails to get any values for $myIPs when it is running during the actual PC shutdown. I can run it interactively (including from the machine SYSTEM account) and it works fine, but somehow when it is run by the system during shutdown, the line $myIPs = @(Get-NetIPAddress -AddressFamily IPv4 | where { $_.InterfaceAlias -notmatch 'Loopback'} |Select IPAddress) returns an empty array. I verified this using logging statements in the function.

This might actually be my problem as well, did you ever fix this, or how did you get logging going within the function?