My PowerShell functions do not appear to be used
Posted
by Frank
on Server Fault
See other posts from Server Fault
or by Frank
Published on 2010-03-21T17:57:13Z
Indexed on
2010/03/21
18:01 UTC
Read the original article
Hit count: 381
powershell
|scripting
Hi there,
I have a ps1 script in which I define 2 functions as such:
function Invoke-Sql([string]$query) {
Invoke-Sqlcmd -ServerInstance $Server -Database $DB -User $User -Password $Password -Query $query
}
function Get-Queued {
Invoke-Sql "Select * From Comment where AwaitsModeration = 1"
}
I then call the ps1 file by typing it in (it's in a folder in the path, and autocompletion works)
However, I cannot start using the functions. I am confused, because when I copy / paste the functions into the console, all is fine and they work. I also have a function defined in my profile, and it works. Where am I thinking wrong, why doesn't it work what I'm trying to do?
© Server Fault or respective owner