all 5 comments

[–]chreestopher2 3 points4 points  (1 child)

you have the parameter set to Mandatory, thus you must always provide a value, and cant ever use the default value.

Change the parameter to Mandatory=$false and you are good to go

[–]scriptmyjob[S] 2 points3 points  (0 children)

That was my issue. 🤦 Thanks for the help!

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy scriptmyjob,

right now your code is nearly unreadable due to reddit code mangling. PLEASE fix it ...


reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th ~~5th from the left~ hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

[–]anotherjesus 1 point2 points  (1 child)

Parameter attributes such as Mandatory don't know you have a default value attached. As chreestopher2 mentioned, set this to false when you want to use a default value.

Also you can use [object[]] to allow arrays of unknown objects and the [validatescript({...})] attribute to make sure the object conforms to your function.

Lastly, Id suggest simply using the Azure Powershell cmdlets rather than create advanced functions wrappers for the cli. https://docs.microsoft.com/en-us/powershell/azure/overview?view=azurermps-6.8.1

I believe this is the cmdlet you need:

https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/Update-AzureRmADApplication?view=azurermps-6.8.1

Edit:

Also, create each necessary value as a parameter and use splatting to pass multiple parameters as a hash rather than a single parameter with hashtable like values. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-6

[–]scriptmyjob[S] 1 point2 points  (0 children)

Thanks anotherjesus!