# Function Alias Question

**URL:** <https://forums.powershell.org/t/function-alias-question/6410>\
**Category:** PowerShell Help\
**Created:** [May 9, 2016, 5:34pm UTC](https://forums.powershell.org/t/function-alias-question/6410 "2016-05-09T17:34:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-innes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/alex-innes/32/129_2.png) [@alex-innes](https://forums.powershell.org/u/alex-innes)\
**Post date:** [May 9, 2016, 5:34pm UTC](https://forums.powershell.org/t/function-alias-question/6410/1 "2016-05-09T17:34:22Z")

</div>

I am unsure why something like this does not work:

I have a function e.g.:

```
function get-name
{
    [CmdletBinding()]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [alias("SamAccountName")]
        $myname
    )

    Begin
    {
    }
    Process
    {
    }
    End
    {
        echo $myname
    }
}
```

Load this function, and then try:

```
get-aduser "name" | get-name
```

This returns nothing.  
Change the Parameter var to $samaccountname it then returns the samaccountname (from the pipeline).  
I thought have the alias there should allow it to return that value from the pipeline?  
Just wondering if this is something that I have misunderstood?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 9, 2016, 9:05pm UTC](https://forums.powershell.org/t/function-alias-question/6410/2 "2016-05-09T21:05:22Z")

</div>

Welcome to the “People annoyed by the ActiveDirectory” module club. I’m not only the president, I’m also a member! 🙂

Seriously, this would work with literally any other command piped to your function _except_ those in the AD module. Those objects are just weird, but there is a workaround:

```
get-aduser "name" | select * | get-name
```

It looks silly to stick “select \*” in the pipeline like that, but it produces an object that is much better behaved than the original.

---

<div class="post-metadata">

**Author:** ![alex-innes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/alex-innes/32/129_2.png) [@alex-innes](https://forums.powershell.org/u/alex-innes)\
**Post date:** [May 9, 2016, 9:37pm UTC](https://forums.powershell.org/t/function-alias-question/6410/3 "2016-05-09T21:37:14Z")

</div>

Aaahhhh, this would explain a lot - I thought I was loosing my mind.

I am glad you cleared this up, I can now give my head a rest from banging it off the desk.

Much appreciated Dave 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:41pm UTC](https://forums.powershell.org/t/function-alias-question/6410/4 "2024-05-16T20:41:26Z")

</div>


