Script to collect information and send E-Mail's RRS feed

  • Question

  • Hello,

    the use case is:

    We have Resource groups created in our environment with Owner Tag.

    The value from Owner is an E-Mail address.

    Now I wan't to run a script that reads the owner tag.After this and E-Mail should send to the Owner address with with the information, which resources are include in the resource group.

    How is this possible?

    Can somebody can give me an sample for this?

    best regards,


    Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; TFS 2013; IIS 7.5

    Friday, October 11, 2019 12:24 PM

All replies

  • Hi,

    That is certainly possible. First you need to find which tool or automation service you want to use so for example you can schedule this to happen once per day. You can of course run it manually on your own once per day. Azure offers many services that can do such thing like Azure Functions, Azure Automation or Logic Apps. Depending on what you choose will also result in what kind of language you want to write this automation. For example if it is PowerShell you can run something like this:

    $tagName = "tag1"
    $p = Get-AzResourceGroup | where {$_.Tags.Keys -contains  $tagName}
    foreach ($c in $p) {$c.Tags.$tagName}

    Of course this is just small example that you have to accommodate to your needs if you choose PS.

    Friday, October 11, 2019 1:24 PM
  •  Hello Stanislav, 

    Great! My preferred way will be an automation account. 

    Is it possible to send EMail's to one tag value also?

    How can this script look like? 

    Thanks for your help!


    Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; TFS 2013; IIS 7.5

    Sunday, October 13, 2019 6:31 AM
  • Hi,

    Sending e-mail is possible. For example if you have Office 365 you can use module like https://www.powershellgallery.com/packages/SendEmail/1.3 to send e-mails.

    I have given you the basic logic of finding resource groups by tags. The rest of the part you have to write it yourself. I cannot write the whole script for you as first this is helping forum and second I do not know the details of the whole logic you want to achieve and your environment.

    Monday, October 14, 2019 5:36 AM