A few years ago, I accidently stumbled upon an "hidden" PowerShell alias in VMware PowerCLI, vc, which can be used instead of Connect-ViServer.
This vc command is invisible to both Get-Command and Get-Alias, it's not recognized by command completion (not that you really need it to), and I could only relate it to Connect-ViServer by its output and behavior.
I found this specific pseudo-alias to be pretty useful in my PowerCLI work, and I always wondered how this worked, and whether there were other such hidden shortcuts.
Today, I searched my system for 2-letter and 3-letter commands unknown to Get-Command, and the only ones that came out beside vc were shortened Get-* commands (as explained by @vrdse below).
- Can anyone explain where/how this
vcpseudo-alias is defined ? - How can I find similar hidden commands more efficiently than with the below script or by sheer luck ?
Here's my (quick and dirty) script for 3-letter aliases, which ran for about an hour (!) on my system, and found nothing but shortened Get-* commands :
(Caution: blindly running random commands as I did is NOT recommended)
$az = [char[]]('a'[0]..'z'[0])
foreach ($i in $az) {
write $i
foreach ($j in $az) {
write $i$j
foreach ($k in $az) {
if (!(gcm -ea ig $i$j$k)) {
try {iex $i$j$k; write-warning $i$j$k} catch {}
}
}
}
}
As I stated already in the comments, PowerShell doesn't require the
Get-ofGet-*commands, such asGet-Vhd. Instead, you can just typeVhd. That being said, you can check for aliases forConnect-ViServer.You see, that in fact there are some aliases to it. One of which is
Get-VC, thusvcis possible.