Link to home
Start Free TrialLog in
Avatar of Christian KAZADi
Christian KAZADiFlag for Canada

asked on

Sending e-mail on maches conditions

Hi all

I have this script :

Get-WmiObject -ComputerName 'dc1' -Class Win32_NetworkAdapter | `
    Where-Object { $_.Speed -ne 2000000000 -and $_.MACAddress -ne $null } | `
    Format-list -Property SystemName,Name,NetConnectionID,Speed,MACAddress

And I would like to receive a e-mail alert when $_.Speed -ne 2000000000 condition is match

I need help, Please

Thank you

CK
Avatar of Jeremy Weisinger
Jeremy Weisinger

You can use Send-Mailmessage to do this. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-6

Substitute the proper parameters for your environment:
$adapterinfo = Get-WmiObject -ComputerName 'dc1' -Class Win32_NetworkAdapter | Where-Object { $_.Speed -ne 2000000000 -and $_.MACAddress -ne $null } 
If($adapterinfo){
    Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String>] [[-SmtpServer] <String>] [-Credential <PSCredential>] [-UseSsl] -From <String>
    } 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial