• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Alert on pending approval request expiration
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • +JavaScript
    • -PowerShell
      • PowerShell Library Source Code
      • -PowerShell samples
        • Alert on pending approval request expiration
        • Building a Managed Unit Dynamically
        • Calculate user mailbox size
        • Checking the uniqueness of a property
        • Create Dynamic Group in PowerShell
        • Export Domain Users to a .csv file
        • Functions for creation of Policy links
        • Get Active Roles Management Shell Module version (with build number)
        • Home Folder Move with User Moves
        • How to schedule the Active Roles Management shell
        • Populating a custom Virtual Attribute with a readable accountExpires timestamp using an Active Roles Policy Script
        • PowerShell: Update Property Generation and Validation policy with a new possible value list
        • Random Password Generation
        • Renaming a user post-creation
        • Working with the mS-DS-ConsistencyGuid attribute
    • +VBScript

Alert on pending approval request expiration

DESCRIPTION

This is a sample that sends email with list of pending approval for which there is no decision more than a few days.


How to use

To use this script, import this script as a new powershell scheduled task script module and create a new scheduled task in ARS, referencing new script module.

The parameters that need to change:

  • SmtpServer - the DNS or NetBIOS name of the host to which to post the message using the SMTP protocol,
  • MailTo - commas separate multiple recipients in the list: ("User1" <User1@e[[ars-script-wiki&mce_rdomain=dell.com:mailto:User1@example.com|]]xample.com>, "User2" <User2@exam[[ars-script-wiki&mce_rdomain=dell.com:mailto:User2@example.com|]]ple.com>, "User3" <User3@exa[[ars-script-wiki&mce_rdomain=dell.com:mailto:User3@example.com|]]mple.com>) ,
  • MailFrom - The e-mail addresses of the principal author or authors of this message,
  • ArsUrl - the URL of ARS Self service site


SCRIPT

#*********************************************************************************

# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

#

# IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

# PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.

#*********************************************************************************

 

 

# number of days before sending alerts

$days = 10

# Set the DNS or NetBIOS name of the host to which to post the message

# using the SMTP protocol.

$SmtpServer = "smtp.mycompany.com"

# Set the port on which the SMTP service is listening

$SmtpPort = 25

# Set the From of email

$MailFrom = "Administrator@mycompany[[ars-script-wiki&mce_rdomain=dell.com:mailto:Administrator@mycompany.com|]].com"

# Set the email subject

$Subject = "Pending approval request expiration"

# Set recipients of alert

$MailTo = "example1@example.co[[ars-script-wiki&mce_rdomain=dell.com:mailto:example1@example.com|]]m"

# Set the URL of ARS Self service site

$ARSurl = "http://ars.mycompany.com/ARServerSelfService"

$MsgText = "The following Active Directory operations are pending approval for more than $days days:"

$needToSend = $false

$now = [DateTime]::Now

$datebefore = $now.AddDays(-$days)

Get-QARSApprovalTask -TaskStatus "Pending" -CreatedBefore $datebefore |

%{

$elapsed = $now - $_.Created

$needToSend = $true

$id = $_.ID

# Link to Approval task

$MsgText += "<p><a href=""$ARSurl/Approval/SearchResult.aspx?TaskID=TASK_BY_ID&itemID=$id"">$id</a>"

$MsgText += " created " + $elapsed.Days + " days ago, pending approval of "

# list of approvers

$first = $true

$_.Approvers |

%{

if ($first -ne $true) {$MsgText += ", "}

$first = $false

$MsgText += $_.NTAccountName

}

$MsgText += "</p>"

}

if ($needToSend)

{

# Specify that the message will be sent using the network

# (SMTP over the network).

$CdoSendUsingPort = 2

$Msg = New-Object -ComObject "CDO.Message"

$Msg.From = $MailFrom

$Msg.To = $MailTo

$Msg.Subject = $Subject

$Msg.HTMLBody = $MsgText

# Configure message

$Msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = $CdoSendUsingPort

$Msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SmtpServer

$Msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $SmtpPort

$Msg.Configuration.Fields.Update()

# Send message

$Msg.Send()

}

  • Script Center: PowerShell
  • Script Center
  • Share
  • History
  • More
  • Cancel
Related
Recommended
  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center