SQL Script to run from a powershell script

I have a sql script that updates a table, I need to run it via a powershell script, but I need to capture a user input first, then use that user input in the sql script.

Your thoughts please.
Roberto Madro R.Programmer AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
It seems that Powershell can use .NET namespaces and libraries so you can use them to construct a powershell script with advanced functonality...for detailed example take a look here
For user input check the script from the Scripting Guy here
Roberto Madro R.Programmer AnalystAuthor Commented:
John; I'm familiar with the scripting guy and the that function you pointed out, I'm more interested in seeing a place holder (or whatever it's) that can hold the input of the user while the SQL script at the backend runs and grab that value, I'm interested in seeing how those two (SQL & PS1) can work together.
John TsioumprisSoftware & Systems EngineerCommented:
Maybe if you give the SQL script and where you want to put the user input would be most helpful....
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Roberto Madro R.Programmer AnalystAuthor Commented:
A simple one;
UPDATE dbo.aspnet_Membership
LastPasswordChangedDate = CURRENT_TIMESTAMP
WHERE UserId= '13CBD9F0-6CA9-4512-96F4-8CA4AAA538C8'

See, but to get the UserID, you have to query another table based on username, and I'm trying not to expose any of this to level 1 support guy (if you know what I mean)
John TsioumprisSoftware & Systems EngineerCommented:
So you want to query a table that retrieves the username and makes the assosiation of the username <--> userID and then insert this info on the SQL script....
Roberto Madro R.Programmer AnalystAuthor Commented:
Yes, so the only value the user is inputting is the "username", and if I can get that and pass it onto the sql script, I can easily do the rest.
John TsioumprisSoftware & Systems EngineerCommented:
Unless you mean the SID of the user where in this case you need
[wmi] "win32_userAccount.Domain=’DomainName’,Name=’TheUsersName’"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roberto Madro R.Programmer AnalystAuthor Commented:
The UserID comes from another table in the database (not AD by any chance, this is application specific), it's looked up via UserName, and all we're doing here is prompting the jr. admin to ask the user for their Username and voila, we'll take it the rest of the way.
(users know their UserName not their UserID, that's a database thing)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.