Mit der Application Catalog-Rolle bietet der Microsoft System Center Configuration Manager ab Version 2012 (SCCM) u.a. die Möglichkeit Anwendungen in einem recht einfach gestalteten Self-Service-Portal zur Verfügung zu stellen. Leider bietet die Rolle keine Funktion um den Administrator bei eingehenden Application Requests über E-Mail zu benachrichtigen. Abhilfe schafft dieses Powershell-Skript:
##################################################################### ### 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 = "smtp.contoso.com" $SenderMail = "configmgr@contoso.com" $TargetMail = "andre.picker@contoso.com" $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. ***" ### Interval ######################################################### $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 }
Das Skript kann im Task-Scheduler eingebunden und über folgenden Befehl aufgerufen werden:
powershell.exe -ExecutionPolicy Bypass -file "emailnotification.ps1"
E-Mail-Notification for Application Catalog:
Download: ConfigMgr: E-Mail-Notification for Application Catalog (TechNet Gallery)
Thank you for this greet work , by the way can we notify the user when his request approved or denied ?
Hi Amir,
yes you can. nice idea. you only need a link between the e-mail-adress and the user and a little more script. the current-state-property values are:
1 Requested
2 Canceled
3 Denied
4 Approved
Maybe I’ll develop it in the coming weeks.
It works great indeed but is it posible to only let the script send the mail one time, if the request is still not approved that it wont send an other mail. I ask this because we want to scedule this powershell script once a day. If an request is stil not denied or approved it again sends the same mail for the pending request.
Dit you als make a notify user script?
Hi Remy,
for scheduling the script for once a day change the following Line:
$interval = $(Get-Date).AddMinutes(-1440)
Let me know if that work for you.
A notify-user-script isn’t planned.
works great, thank you Andre.
I setup SMTP on my SCCM server, configured the first few lines as follows:
$SmtpServer = „sccm.mycompany.com“
$SenderMail = „itrequest@mycompany.com“
$TargetMail = „helpdesk@mycompany.com“
The script runs, as I run it DIRECTLY from powershell, but I get NOTHING in my SMTP logs.
I have extensively tested SMTP, and it is working, with logs to prove it, but either I am missing filling out something else in the script, or it’s just not working for me 🙁
SCCM 2012 on a Windows 2012 Server.
Have you configured the mail server? The Server must accept anonymous SMTP.
Pingback: SCCM Community Meeting in Munich 2016-09-16 | Crankdesk…