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.)