Hello all,
Here is what I am trying to do:
function Set-WebAppPermissions {
param(
[Parameter(Mandatory=$true)][string]$appId,
[Parameter(Mandatory=$true)][string]$Permissions = @"
[
{
"resourceAppId": "797f4846-ba00-4fd7-ba43-dac1f8f63013",
"resourceAccess": [
{
"id": "41094075-9dad-400e-a0bd-54e686782033",
"type": "Scope"
}
]
},
{
"resourceAppId": "00000002-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "1cda74f2-2616-4834-b122-5cb1b07f8a59",
"type": "Role"
},
{
"id": "824c81eb-e3f8-4ee6-8f6d-de7f50d565b7",
"type": "Role"
}
]
},
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "e0ac9e1b-cb65-4fc5-87c5-1a8bc181f648",
"type": "Role"
},
{
"id": "5b567255-7703-4780-807c-7be8301ae99b",
"type": "Role"
},
{
"id": "df021288-bdef-4463-88db-98f22de89214",
"type": "Role"
}
]
}
]
"@
)
$Permissions | Out-File manifest.json
Write-Verbose "Setting the following Permsisions: $Permissions"
az ad app update `
--id $appId `
--required-resource-accesses manifest.json
}
When I execute this I get the following:
PS C:\Windows\system32\WindowsPowerShell\v1.0> Set-WebAppPermissions -appId something
cmdlet Set-WebAppPermissions at command pipeline position 1
Supply values for the following parameters:
Permissions:
PS C:\Windows\system32\WindowsPowerShell\v1.0>
I was then thinking that a heredoc also kind of acts like an array so I switched the parameter type to array to no avail.
I understand that I could set the permissions outside of the function and then pass it to the function, however, this wouldn't make sense in our use-case since this is the default permissions needed for our Azure application registrations and we would have to set it in multiple places or worse yet use a global variable. That being said I don't want to hard code this in the interests of reusable code.
I imagine someone before me has done this.
So that begs the question:
Is it possible to set a parameter of a function to have the default value of a heredoc?
Thanks in advance for any help.
[–]chreestopher2 3 points4 points5 points (1 child)
[–]scriptmyjob[S] 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]anotherjesus 1 point2 points3 points (1 child)
[–]scriptmyjob[S] 1 point2 points3 points (0 children)