Sync Azure RemoteApp Collection Membership with Azure Automation Part 2


Updated version with blogpost can be found here:

Last month I created an Azure Automation workflow which will add and remove members from an Azure Active Directory to a Hybrid Azure RemoteApp collection. With this runbook you get an automated sync solution between an AD Group and an Azure RemoteApp collection. The first version was not complete in terms of reporting what it actually did; which users were added and which were removed. I have now developed a second version of this runbook which will send an email with the results of the runbook to an email address.

To implement this new version of the runbook you have to first import the first version of the runbook by executing the following steps:

When successfully added the first version of the runbook execute the following update steps:

  1. Download the updated runbook from this location:
  2. Import this script as an Azure Automation Runbook in your Azure Environment
  3. Create a 2nd Azure Credential which will have your email environment credentials.
  4. Edit the runbook so both credentials will be used in the runbook. You have to change the following lines in the runbook:
     $Cred = Get-AutomationPSCredential -Name 'Azure_Subscription'
     Add-AzureAccount -Credential $Cred
     Select-AzureSubscription -SubscriptionName '<< SUBCRIPTION_NAME >>'


    $MailCred   = "<< ENTER Azure AutomationCredential for Mail >>"
  5. After changing the above lines the following lines need to be changed before you can test the Runbook:
    $userid     = "<< ENTER USERID >>" 


    Send-MailMessage -To $Mail_Destination -Subject $subject -Body $Body -Port 587 -SmtpServer "<< ENTER MAILSERVER >>" -From $userid -BodyAsHtml -Credential $Cred
  6. The next step is to test the runbook, you will need to enter the following parameters each time you execute the runbook:
    1. AD_Group which will have the Azure AD Group which has the users
    2. RA_Collection which will have the name of the collection to which the users need to be added
    3. Mail_Destination which will have the email address where the reports need to be send to
  7. If the test is successfully you can publish the runbook
  8. The next step is to unlink the runbook and link it again with the above parameters.

After the execution of the runbook the users of the AD Group will be added to the Azure RemoteApp collection. The results of the runbook execution will be send to the email address. See below an example of the email which will be send:

One thought on “Sync Azure RemoteApp Collection Membership with Azure Automation Part 2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.