Open mozzis opened 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)
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.
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?
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