Solved

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

Posted on 2012-12-28
8
305 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
  • 4
  • 2
  • 2
8 Comments
 
LVL 28

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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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 28

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now