Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Cannot figure out how to feed a list from a text document into an array

$
0
0

I’m trying to add a lot of domains to an app in Azure. This works:

Set-AzureRmWebapp -Name “cvproddashboard” -ResourceGroupName “cvprodwestus” -HostNames @(‘AppName.azurewebsites.net’,’domain1.com’,’domain2.com’,’domain3.com’,’domain4.com’,’domain5.com’,’domain6.com’)

But I want to feed it a list of those domains instead so I tried this.

$domains = Get-Content “C:MehDomains.txt”

My Domains.txt looks like this:

‘advisorsbblistens.com’,’ahnulistens.com’,’ahnulistensecomm.com’,’ahnulistensphone.com’,’alamolistens.com’,’alaskalistenscareers.com’

Then I run:

Set-AzureRmWebapp -Name “AppName” -ResourceGroupName “RGname” -HostNames $domains

When I try that it seems to read the list fine but spits back an error.

WARNING: – Could not set custom hostname ”AppName.azurewebsites.net’,’domain1.com’,’domain2.com’,’domain3.com’,’domain4.com’,’domain5.com’,’domain6.com”’. Details: Microsoft.Rest.Azure.CloudException: DomainName validation failed. Details: Top level domain cannot be null or empty

I’m fairly certain I am trying to feed this list as a parameter incorrectly. Any ideas?

submitted by /u/mikmeh
[link] [comments]

The post Cannot figure out how to feed a list from a text document into an array appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793