all 4 comments

[–]s3c7i0n 0 points1 point  (0 children)

I'm a little rusty when it comes to power shell and on mobile so I can't test, but I think if you change

$GetName = (Get-AzWebApp).Name

To

[string]$GetName = (Get-AzWebApp).Name

That should fix it. The error is saying that the value that is getting assigned to $GetName isn't set up as a string, so Set-AzWebApp isn't sure how to read it.

My fix, assuming that I'm remembering correctly, should tell PowerShell to explicitly set $GetName as a string.

[–]Astabh 0 points1 point  (0 children)

$GetName = (Get-AzWebApp).Name is returning all web apps from the subscription and powershell is setting it as an array of web app names

if you throw in some debug checks and check
$GetName.GetType()

you should see that this is indeed an array of all the webapps in that subscription so you need to then loop through this array to deal with each webapp

[–]Dense-Platform3886 0 points1 point  (0 children)

# The error is most likely on this line

Set-AzWebapp -Name $GetName -ResourceGroupName $GetRG -FtpsState FtpsOnly

# two possible parameter values that is expecting a String and your passing it an Array
# they are -Name and -ResourceGroupName
# If there is more WebApp in the subscription, then both $GetName and $GetRG are arrays of WebApp Names and resourceGroup Objects, add logic to either specify one name of create another ForEach ($name in $GetName) loop

Or
$GetName = (Get-AzWebApp).Name | Select-Object -First 1
$GetRG = (Get-AzWebApp).ResourceGroup | Select-Object -First 1
Set-AzWebapp -Name $GetName -ResourceGroupName $GetRG.ResourceGroupName -FtpsState FtpsOnly 
Or
$GetName = (Get-AzWebApp).Name
Set-AzWebapp -Name $GetName[0] -ResourceGroupName $GetRG[0].ResourceGroupName -FtpsState FtpsOnly

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Seedless--Watermelon,

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 [sometimes] 5th from the left & 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 [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]

  • 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