Hi,
Is there anyway to build a command in a variable, then run it.
I'm trying to do this by building a string from a sql query, then run it. I thought I had done this before, but the more I think of it I'm not sure I have.
I've tried creating an alias, but the command is not recognised. Here is an example of what I am attempting (it's not actually what I want to do, but is a simple view of something similar)
Thanks in advance.
Invoke-Sqlcmd -ServerInstance db -Query "select 'get-qaduser ' + Userid as string from Users where userID like 'bbl12%'" | foreach {
$string = $_.string
# now I would like to run the command.
}