Why wouldn't a Read-Host input not get applied later in script?

First off I would like to say I am new to powershell scripting and am experimenting with some ideas. However I keep running into an error and not sure why. Any advice would be much appreciated.  I am doing this in a windows 2016 environment.

$domainname = (Read-Host "Enter name for domain.")

Install-WindowsFeature AD-Domain-Services -IncludeManagementTools

Import-Module ADDSDeployment

Install-ADDSForest -DomainName "$domainmane"
Set-TimeZone -Id "Mountain Standard Time"

I get:
Install-ADDSForest : Cannot bind argument to parameter 'DomainName' because it is an empty string.

I have also tried it as:

$domainname = Read-Host "Enter name for domain."

$domain = -domainname $domainname
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools

Import-Module ADDSDeployment

Install-WindowsFeature ADDSForest
Set-TimeZone -Id "Mountain Standard Time"

However any time I attempt this I receive the following error:
Install-WindowsFeature : A parameter cannot be found that matches parameter name 'DomainName'.
At line:10 char:35
+ Install-WindowsFeature ADDSForest -DomainName "$domainmane"
+                                   ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Install-WindowsFeature], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand

Thank you in advance!
Darren BowdenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have a misspelling there.
Install-ADDSForest -DomainName "$domainmane"
Mane instead of Name.  So should be
Install-ADDSForest -DomainName $domainname

Open in new window

(no need for the quotes around the variable - it's already a string)

Using the PowerShell ISE or other tools with tab completion can really help with avoidance of misspellings.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Putting Set-StrictMode -Version 2.0 as first statement can help with that. You get an error whenever an unitialized variable is used to get values.
Darren BowdenAuthor Commented:
I ended up getting it to work by adding a echo -domainname at the end of the read-host. Thanks for the input!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
footech is absolutely correct. "adding a echo -domainname at the end of the read-host" doesn't make any sense, sorry.
Darren BowdenAuthor Commented:
Answer was not suggested, so the solution I found im giving as information for anyone else having the same problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.