Discussion:
Functions in Microsoft.PowerShell_profile.ps1
(too old to reply)
Tom
2017-11-28 12:15:00 UTC
Permalink
Hi,

We are running Windows 7 with PowerShell 2.0 and I'm trying to create a few aliases and functions in the Microsoft.PowerShell_profile.ps1 files so that all new shells can pick up the new alias/commands. I have the following in the file:

function sv {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" startview $args[0]
}
#
function ev {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" endview $args[0]
}

The "ev" functions works every time, however the "sv" does not. I can type the command into the terminal (using a different function name foo or bar) and it works for that shell... I've tried to change it to pass an argument in:

function sv($view) {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" startview $view
}

Again, starting a new Powershell terminal no luck, but typing it in on the command line it works fine. What am I doing wrong here? What am I' missing?

Thanks for any help in advance.
Tom
Tom
2017-11-28 12:35:18 UTC
Permalink
Post by Tom
Hi,
function sv {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" startview $args[0]
}
#
function ev {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" endview $args[0]
}
function sv($view) {
$command = "C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin\cleartool.exe"
& "$command" startview $view
}
Again, starting a new Powershell terminal no luck, but typing it in on the command line it works fine. What am I doing wrong here? What am I' missing?
Thanks for any help in advance.
Tom
My bad.... There already is an alias "sv"....

PS U:\> which sv

CommandType Name Definition
----------- ---- ----------
Alias sv Set-Variable


Please excuse the noise....

Tom

Loading...