Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Can't get ValueFromPipelineByPropertyName to work with Get-ADComputer

$
0
0

Hi!

I am trying to create a CMDlet that will get input from Get-ADuser or Get-ADComputer but i can't get it to work with the ValueFromPipelineByPropertyName property.

The script below only outputs the name of the user or computer but it does not work with Get-ADuser or Get-ADcomputer, it does work if i create my own object as you can see below

function Just-a-Test
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
                   [Alias("Name")]
        $TheName
    )

    Begin
    {
    }
    Process
    {
    Write-Host $thename
    }
    End
    {
    }
}


$obj = New-Object psobject -Property @{name = "test"}  


# Output: Test
$obj | Just-a-Test 

#Output: Just empty rows, Why oh why?
Get-ADComputer -Filter * | Just-a-Test 

Any idea why?

Thanks!


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>