forked from jjmolerof/PowerShellScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-ParameterAlias.ps1
More file actions
37 lines (32 loc) · 1003 Bytes
/
Copy pathGet-ParameterAlias.ps1
File metadata and controls
37 lines (32 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[CmdletBinding()]
Param(
[parameter(Mandatory=$False)]
[string[]]$cmdlet,
[Parameter(Mandatory=$False,Position=1)]
[String]$ParameterOrAlias)
function GetOutput
{
$Properties = [Ordered]@{
Command = $Command.Name
Parameter = $Item.Name
Alias = $Item.Aliases}
$Out = New-Object -TypeName PSObject -Property $Properties
Write-Output $Out
}
if ($cmdlet) {$AllCommands = Get-Command $cmdlet}
else {$AllCommands = Get-Command}
foreach ($Command in $AllCommands)
{
if ($ParameterOrAlias)
{
$Alias = @()
$Alias = Get-Help $Command.Name -Parameter * -ErrorAction SilentlyContinue | Where-Object {($_.Aliases -like $ParameterOrAlias -or $_.Name -like $ParameterOrAlias) -and $_.Aliases -notlike "None"}
if ($Alias) {foreach ($Item in $Alias) {GetOutput}}
}
else
{
$Alias = @()
$Alias = Get-Help $Command.Name -Parameter * -ErrorAction SilentlyContinue | Where-Object {$_.Aliases -and $_.Aliases -notlike "None"}
if ($Alias) {foreach ($Item in $Alias) {GetOutput}}
}
}