Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Problems consuming parameters by propertyName from ADObjects using Alias

$
0
0

Hi!

I have a parameter named "signature" which I want to be able to pipe data to from ADObjects (from the module ActiveDirectory). Adding an alias named "samaccountname" to the parameter "signature" should populate "signature" with the samaccountnames from the ADObjects. But that do not work. If I put an "select * " in between in the pipe, it do work. Why? 

Code Example:

Set-StrictMode -Version Latest

function Do-StuffToObject {
  [cmdletbinding()]
  Param(
    [Alias("samaccountname")]
    [Parameter(Position=0,ValueFromPipelinebyPropertyName=$True)]
    [string] $signature = $null
  )
  PROCESS {
    Write-Host "Signatur: $signature"
  }
}


$obj = Get-ADUser kalle

# The following line generates output: "Signature: "
$obj |  Do-StuffToObject

# following line generates output: "Signature: kalle"
$obj | Select * |  Do-StuffToObject


Viewing all articles
Browse latest Browse all 10624

Latest Images

Trending Articles



Latest Images