Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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,
0
namerg
Asked:
namerg
  • 4
  • 2
  • 2
1 Solution
 
becraigCommented:
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
 
namergSystems AdministratorAuthor Commented:
Hmm, what do you mean?  I do not understand your question.
0
 
SubsunCommented:
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
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
namergSystems AdministratorAuthor 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
0
 
SubsunCommented:
'Single Quote' does not expand the variable but "Double quotes" should..
This is what I get.. Example
0
 
namergSystems AdministratorAuthor Commented:
Ohh my bad sorryyyy....let me try....
0
 
namergSystems AdministratorAuthor Commented:
You got it. thank you.
0
 
becraigCommented:
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now