1.    12 Dec 2006 #1
    Mike Gale Guest

    Alias Replacement


    Has anyone developed a tool to replace aliases in code with the standard
    (verb-noun) names for cmdlets?

    (I'm thinking of something that will process a script, or console capture.)
      My System SpecsSystem Spec

  2.    13 Dec 2006 #2
    Peter Schneider [MVP] Guest

    Re: Alias Replacement


    Hi Mike!

    As far as I know PrimalScript (www.primalscript.com) has support for
    expanding alias names to cmdlet names

    You could also use something like this:

    But: The used regex surly needs to be tweaked.... it's just a quick and
    dirty hack.. ;-)
    Also the alias names for
    ? --> where and % --> foreach are not expanded...


    # ------ save to
    resolve.ps1 ------------------------------------------------
    # usage: . \resolve inputFile.ps1 outputFile.ps1

    param ( [string] $inputFile,
    [string] $outputFile)

    begin {

    function resolveDefinition ( $aliasname ) {

    get-alias | where { $_.Name -eq $aliasname } | %{ $_.Definition }

    }

    }

    process {

    $aliasnames = (get-alias | sort Name -desc)

    (get-content $inputFile) | foreach {

    $result = $_

    foreach ($alias in $aliasnames) {

    if ($alias.Name[0] -match "[a-zA-Z]") {
    if($result -match "\b" + $alias.Name +"\b") {
    $result = $result -replace ($alias.Name),
    (resolveDefinition($alias.Name))
    }
    }
    }

    $result

    } | set-content $outputFile


    }

    #--------------------------------------------------------



    "Mike Gale" <MikeGale@discussions.microsoft.com> schrieb im Newsbeitrag
    news:E27439A1-A0FF-4EEA-9DD8-EB2460F194CD@microsoft.com...
    > Has anyone developed a tool to replace aliases in code with the standard
    > (verb-noun) names for cmdlets?
    >
    > (I'm thinking of something that will process a script, or console
    > capture.)



      My System SpecsSystem Spec

  3.    14 Dec 2006 #3
    Mike Gale Guest

    Re: Alias Replacement


    Thanks Peter.

    I like to suggest incorporating something like this into Community
    Extensions and eventually into Powershell itself.
      My System SpecsSystem Spec

  4.    14 Dec 2006 #4
    Keith Hill [MVP] Guest

    Re: Alias Replacement


    "Mike Gale" <MikeGale@discussions.microsoft.com> wrote in message
    news:CD452FF9-CF2F-45AD-B657-385D32D70F15@microsoft.com...
    > Thanks Peter.
    >
    > I like to suggest incorporating something like this into Community
    > Extensions and eventually into Powershell itself.


    FYI this is there if you use the PSCX profile. Well it is part of the tab
    expansion function e.g.

    > gal!<press tab> == expands to ==> Get-Alias


    --
    Keith

      My System SpecsSystem Spec


Similar Threads
Thread Forum
how to access alias::* from anywhere.
To illustrate my question i'll just give the scenario i'm facing right now. I'm using uTorrent and would like to enter as default download path...
Vista General
Get-Alias and its reverse
Powershell provides the inaptly-named commandlet Get-Alias, thus: >get-alias gci CommandType Name Definition ----------- ---- ---------- Alias...
PowerShell
Something that Alias would love
http://www.sillylug.com/index.php?option=com_content&task=view&id=20&Itemid=33
Vista General
Alias will like this
I am sure Alias will like this: Even Softies get the Vista installation blues http://blogs.zdnet.com/microsoft/?p=531
Vista General
Ping Alias...
Did you ever receive your Solaris? -- Priceless quotes in m.p.w.vista.general group: http://protectfreedom.tripod.com/kick.html Most recent...
Vista General
Set alias with parameter
I need some verification about a limitation with Set-Alias. It does not appear that you can specify any parameters with Set-Alias. For example, if...
PowerShell
Reg:Alias
Hi All Is there a dog food alias for windows mail If so can some one send me an email with the same -- With Regards Raul Thomas
Vista mail

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 16:06.
    .