Solved

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

Posted on 2012-12-28
8
309 Views
Last Modified: 2012-12-28
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,
0
Comment
Question by:namerg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 38728001
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)'
0
 

Author Comment

by:namerg
ID: 38728076
Hmm, what do you mean?  I do not understand your question.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38728077
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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:namerg
ID: 38728098
Nope. I get the following:

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

Thanks, G
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38728124
'Single Quote' does not expand the variable but "Double quotes" should..
This is what I get.. Example
0
 

Author Comment

by:namerg
ID: 38728130
Ohh my bad sorryyyy....let me try....
0
 

Author Comment

by:namerg
ID: 38728135
You got it. thank you.
0
 
LVL 29

Expert Comment

by:becraig
ID: 38728163
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 .
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question