Link to home
Start Free TrialLog in
Avatar of namerg
namergFlag for United States of America

asked on

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

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,
Avatar of becraig
becraig
Flag of United States of America image

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)'
Avatar of namerg

ASKER

Hmm, what do you mean?  I do not understand your question.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of namerg

ASKER

Nope. I get the following:

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

Thanks, G
'Single Quote' does not expand the variable but "Double quotes" should..
This is what I get.. User generated image
Avatar of namerg

ASKER

Ohh my bad sorryyyy....let me try....
Avatar of namerg

ASKER

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 .