Functions/Set-ARMmetadata.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
function Set-ARMmetadata { <# .SYNOPSIS Creates a metadata.json file for your ARM template .DESCRIPTION Creates a metadata.json file for your ARM template .EXAMPLE $meta = @{ ItemDisplayName = "Blank Template" Description = "A blank template and empty parameters file" Summary = "A blank template and empty parameters file. " GitHubUsername = "torgro" } Set-ARMmetadata @meta This will create a file metadata.json containing the information in $meta .INPUTS string .OUTPUTS .NOTES Author: Tore Groneng Website: www.firstpoint.no Twitter: @ToreGroneng #> [cmdletbinding()] Param( $ItemDisplayName , $Description , $Summary , $GitHubUsername , $FileName = "metadata.json" ) $f = $MyInvocation.InvocationName Write-Verbose -Message "$f - START" $resolvedFilename = Resolve-Path -Path $FileName -ErrorAction SilentlyContinue if (-not $resolvedFilename) { $resolvedFilename = Join-Path -Path $PSScriptRoot -ChildPath metadata.json } $output = [pscustomobject]@{ itemDisplayName = $ItemDisplayName description = $Description summary = $Summary githubUsername = $GitHubUsername dateUpdated = (Get-Date).ToString("yyyy-MM-dd") } $json = $output | ConvertTo-Json Write-Verbose -Message "$f - json output $json" Write-Verbose -Message "$f - Writing to file [$resolvedFilename]" Set-Content -Path $resolvedFilename -Value $json -Encoding UTF8 Write-Verbose -Message "$f - END" } |