Istanbul/Turkey

41- SCCM Email Notification for Application Requests

There is no build-in email notification feature in SCCM for application requests. I found the following script written by Andre Picker and it works great. I wanna thank to Andre for sharing this solution.

Script is triggered by a scheduled task. I set it to run every 1 hour.

https://gallery.technet.microsoft.com/ConfigMgr-E-Mail-24396998#content

First created the emailnotification.ps1 script in the following path c:\emailnotification\emailnotification.ps1. 

 

 

#####################################################################
### E-Mail-Notification for Application-Request in ConfigMgr 2012 R2
### powered by Andre Picker - www.clientmgmt.de
### http://twitter.com/clientmgmt
#####################################################################

### E-Mail Settings #################################################

$SmtpServer = "Yoursmtpserveripaddress OR FQDN"
$SenderMail = "senderemailaddress"
$TargetMail = "receivingemailaddress"
$Subject = "Application Catalog Request"
$Message = "You have received a new Application Request from System Center Configuration Manager:`n"
$Footer = "To process the request go to: \Software Library\Overview\Application Management\Approval Requests.`n`n*** This is an automatically generated email. Please do not reply to this message. ***"

### Queryinterval ####################################################

$interval = $(Get-Date).AddMinutes(-60)

### Get SMS.Sitecode #################################################

$smsproviderloc = "select * from sms_providerlocation"
$sitecode = Get-WmiObject -Query $smsproviderloc -Namespace "root\sms" -ComputerName localhost
$sitecode = $sitecode.sitecode

### Query ############################################################

Get-WmiObject -Namespace "root\SMS\Site_$sitecode" -Class SMS_UserApplicationRequest | where {$_.CurrentState -match "1" -and [Management.ManagementDateTimeConverter]::ToDateTime($_.LastModifiedDate) -gt $interval} | Foreach-Object {

$User = $_.User
$Application = $_.Application
$Comments = $_.Comments
$Date = [Management.ManagementDateTimeConverter]::ToDateTime($_.LastModifiedDate)

Send-MailMessage -From $SenderMail -Subject "$Subject from $User" -To $TargetMail -Body "$Message`nUser: $user`nApplication: $Application `nDate: $Date `nComments: $Comments `n`n$Footer" -SmtpServer $SmtpServer
}

 

 

Modify the following lines according to your environment and save it:

$SmtpServer = "Yoursmtpserveripaddress OR FQDN"
$SenderMail = "senderemailaddress"
$TargetMail = "receivingemailaddress"

 

Then create the scheduled task.

 

 

 

I set it to run this task every 1 hour

 

 

 

Click Edit to add the action

 

 

 

Action: Start a program

Program: powershell.exe

Add Arguements: -ExecutionPolicy Bypass -file "C:\emailNotification\emailnotification.ps1"

 

 

 

 And the email you would receive will be in this format

 

 

  • Hits: 7149