How to echo captured values whithin a Read-Host statement ?

namerg
namerg used Ask the Experts™
on
Hello all,

I am working in a little project that involves reading a csv file, query ad against the csv file and set the the right values in AD.

Through the code I have captured the following values

$AD_USER.sn
$InputLastName

$InputLastName = Read-Host 'Type the new Last Name:'
$NewLastName = Read-Host 'Are you sure, you want to replace the following lastname "$($AD_USER.sn)" by $($InputLastName) (Y/N)'

So, when I ask the question: 'Are you sure, you want to replace the following lastname "$($AD_USER.sn)" by $($InputLastName) (Y/N)',

So, not sure how to echo the values previously captured on $AD_USER.sn and $InputLastName in the Read-Host statement

Thanks for your help,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Are you sure you dont want to make do it this way ?


$InputNewLastName = Read-Host 'Type the new Last Name:'
$NewLastName = Read-Host 'Are you sure, you want to replace the following lastname "$($AD_USER.sn)" by $($InputNewLastName) (Y/N)'
namergSystems Administrator

Author

Commented:
Hmm, what do you mean?  I do not understand your question.
IT Infrastructure Architect
Commented:
Try
$InputNewLastName = Read-Host "Type the new Last Name"
$NewLastName = Read-Host "Are you sure, you want to replace the following lastname $($AD_USER.sn) by $($InputNewLastName) (Y/N)"

Open in new window

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

namergSystems Administrator

Author

Commented:
Nope. I get the following:

Are you sure, you want to replace the following lastname $($AD_USER.sn) by $($InputLastName) (Y/N)

Thanks, G
Subash SundharanIT Infrastructure Architect

Commented:
'Single Quote' does not expand the variable but "Double quotes" should..
This is what I get.. Example
namergSystems Administrator

Author

Commented:
Ohh my bad sorryyyy....let me try....
namergSystems Administrator

Author

Commented:
You got it. thank you.
Ok so I see the issue with my copy and paste was that I did not change the single quote at the end to a double quote lol .

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial