I need help, How can i add description to my specify addresses of pings the purpose of their description.
I do script with test-connection command for some devices in my network.
I expect the result with description of ping addresses.
This is my script:
###Checking empty variables###
if ($workagain -eq $null) {
Write-Host “variable with arrays that started working again is empty” -Backgroundcolor Red
}
else {
Send-MailMessage -From $From -to $To -Subject “the boards were up” -Body $workagain -BodyAsHtml -SmtpServer $SMTPServer -Port $SMTPPort -Credential ($Credential)
Write-Host “An email has been sent with addresses that are pinging again” -Backgroundcolor DarkMagenta
}
if ($lostpings -eq $null) {
Write-Host “a variable with arrays that have been non-pinging is empty” -Backgroundcolor Red
}
else {
Send-MailMessage -From $From -to $To -Subject “Lost Pings” -Body $lostpings -BodyAsHtml -SmtpServer $SMTPServer -Port $SMTPPort -Credential ($Credential)
Write-Host “An email has been sent with addresses that are not pinging” -Backgroundcolor DarkMagenta
}
What kind of description do you expect? Could you show an example?
Unfortunately your code is very hard to read as you’re using Polish terms and variable names. And it looks like you’re either using functions you declared outside of the code you’re showing or you forgot some $ charachters.
Haven’t seen it when I pasted my code here, a few items were changed - mainly “$” was changed for HTML marker, so i correct code from the mainly comment.
This is my example of result whitch i need:
10.0.0.1 - ping ok - London
10.0.0.2 - ping ok - London
10.0.0.3 - ping ok - London
10.0.0.4 - ping ok - London
10.0.0.5 - ping ok - Paris
10.0.0.6 - ping lost - Paris
10.0.0.7 - ping lost - Paris
10.0.0.8 - ping lost - Paris
10.0.0.9 - ping ok - Moscow
10.0.0.10 - ping ok - Moscow
10.0.0.11 - ping ok - Moscow
10.0.0.12 - ping lost - Moscow
So every 4 pings of the IP is another localization and i need attach it for every of ip addresses.
Test-Connection does not provide these kind of information. You would need to inject them by yourself to the result. If you have a kind of dictionary where you store those information about your network you could combine both informations if you like.
Thank you for reply
I know, but i need send emails with reports which only information which of them are not responding. I’m sure, that exist commands which connect addresses of the variable “lostpings” with list describing them addresses, but i don’t know them.