<commit_before>﻿<#
    .SYNOPSIS
       Add a synopsis here to explain the PSScript. 

    .Description
        Give a description of the Script!!!!!!

#>
Param(

)
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$CompletedParameters = Write-StartingMessage -CommandName Save-AzureRMResourceProperties

$GlobalVars = Get-BatchAutomationVariable -Prefix 'zzGlobal' `
                                          -Name 'SubscriptionName',
                                                'SubscriptionAccessCredentialName',
                                                'ResourceGroupName',
                                                'WorkspaceId'

$SubscriptionAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.SubscriptionAccessCredentialName
$WorkspaceCredential = Get-AutomationPSCredential -Name $GlobalVars.WorkspaceID
$Key = $WorkspaceCredential.GetNetworkCredential().Password

Try
{
    Connect-AzureRmAccount -Credential $SubscriptionAccessCredential `
                           -SubscriptionName $GlobalVars.SubscriptionName
    
    Do
    {
        $ResourceArray = @()
        $Resource = Get-AzureRMResource -ExpandProperties
        foreach($_Resource in $Resource)
        {
            $obj = @{
                'Name' = $_Resource.Name
                'ResourceId' = $_Resource.ResourceId
                'ResourceName' = $_Resource.ResourceName
                'ResourceType' = $_Resource.ResourceType
                'ResourceGroupName' = $_Resource.ResourceGroupName
                'Location' = $_Resource.Location
                'SubscriptionId' = $_Resource.SubscriptionId
            }
            Foreach($PropertyName in ($_Resource.Properties | Get-Member -MemberType NoteProperty).Name)
            {
                $obj.Add("Property-$PropertyName", $_Resource.Properties.$PropertyName) | Out-Null
            }
            $ResourceArray += $obj
        }

        Write-LogAnalyticsLogEntry -WorkspaceId $GlobalVars.WorkspaceId -Key $Key -Data $ResourceArray -LogType 'AzureResourceProperty_CL'

        Start-Sleep -Seconds 30
    }
    While($True)
}
Catch
{
    $Exception = $_
    $ExceptionInfo = Get-ExceptionInfo -Exception $Exception
    Switch ($ExceptionInfo.FullyQualifiedErrorId)
    {
        Default
        {
            Write-Exception $Exception -Stream Warning
        }
    }
}

Write-CompletedMessage @CompletedParameters<commit_msg>turn into a 1 per hour run<commit_after>﻿<#
    .SYNOPSIS
       Add a synopsis here to explain the PSScript. 

    .Description
        Give a description of the Script!!!!!!

#>
Param(

)
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$CompletedParameters = Write-StartingMessage -CommandName Save-AzureRMResourceProperties

$GlobalVars = Get-BatchAutomationVariable -Prefix 'zzGlobal' `
                                          -Name 'SubscriptionName',
                                                'SubscriptionAccessCredentialName',
                                                'ResourceGroupName',
                                                'WorkspaceId',
                                                'SubscriptionAccessTenant'

$SubscriptionAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.SubscriptionAccessCredentialName
$WorkspaceCredential = Get-AutomationPSCredential -Name $GlobalVars.WorkspaceID
$Key = $WorkspaceCredential.GetNetworkCredential().Password

Try
{
    Connect-AzureRmAccount -Credential $SubscriptionAccessCredential `
                           -SubscriptionName $GlobalVars.SubscriptionName `
                           -Tenant $GlobalVars.SubscriptionAccessTenant
    
   
    $ResourceArray = @()
    $Resource = Get-AzureRMResource -ExpandProperties
    foreach($_Resource in $Resource)
    {
        $obj = @{
            'Name' = $_Resource.Name
            'ResourceId' = $_Resource.ResourceId
            'ResourceName' = $_Resource.ResourceName
            'ResourceType' = $_Resource.ResourceType
            'ResourceGroupName' = $_Resource.ResourceGroupName
            'Location' = $_Resource.Location
            'SubscriptionId' = $_Resource.SubscriptionId
        }
        Foreach($PropertyName in ($_Resource.Properties | Get-Member -MemberType NoteProperty).Name)
        {
            $obj.Add("Property-$PropertyName", $_Resource.Properties.$PropertyName) | Out-Null
        }
        $ResourceArray += $obj
    }

    Write-LogAnalyticsLogEntry -WorkspaceId $GlobalVars.WorkspaceId -Key $Key -Data $ResourceArray -LogType 'AzureResourceProperty_CL'
}
Catch
{
    $Exception = $_
    $ExceptionInfo = Get-ExceptionInfo -Exception $Exception
    Switch ($ExceptionInfo.FullyQualifiedErrorId)
    {
        Default
        {
            Write-Exception $Exception -Stream Warning
        }
    }
}

Write-CompletedMessage @CompletedParameters
{'fraction_non_alphanumeric': 0.0851063829787234, 'fraction_numerical': 0.0006137479541734861, 'mean_word_length': 2.1299615877080664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1558972', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1176, 'n_words': 225}