# Friday, October 02, 2009

ArgumentTransformationAttributes are attached to function parameters. They intercept the value coming in and optionally transform it before it is assigned to the target parameter. This is how the powershell type system is enforced:

function Foo ( [string]$str ) { ... }
(gi function:foo).parameters.str.attributes
TypeId
------
System.Management.Automation.ArgumentTypeConverterAttribute
System.Management.Automation.ParameterAttribute

This type converter derives from ArgumentTransformationAttribute. It uses the public utility type [Management.Automation.LanguagePrimitives] (which is full of cool stuff btw) to coerce incoming types to the designated type constraint, in this case [string].

As an aside, you can use the credential attribute on a function parameter too:

function do-something ([system.management.automation.credential()]$cred) { $cred }
do-something # get-credential dialog pops up if $cred is not explicitly passed

And while a little strange but definitely empowering from a future extensibility point of view, you can decorate parameters with entirely inappropriate attributes:

function Foo ( [obsolete($true)][string]$bar ) { ... }

System.ObsoleteAttribute is used in C#/VB.NET to tell the compiler that usage of the decorated item should raise a warning (false) or error (true)

posted on Friday, October 02, 2009 8:46:51 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
Related posts:
PowerShell Script Provider
PowerShell ISE Hacking: Change default save encoding to ASCII
PowerShell 2.0 – PSCX Labs: Invoke-Reflector
PowerShell 2.0 – Developer Essentials #1 – Initializing a Runspace with a Module
SharePoint Resources & Localization – What, Where and Why?
PowerShell 2.0 – Partial Application of Functions and Cmdlets

Referred by:
http://twitturls.com/ [Referral]
http://favit.com/ [Referral]
http://twitter.com/ [Referral]
http://iconfactory.com/twitterrific [Referral]
http://technorati.com/posts/Jrto5IABKs5AWf7_9jEdEtO5GeZ_WHhj... [Referral]
PowerShell (www.google.co.jp) [Referral]
powershell params attributes (www.google.com.mx) [Referral]
http://www.google.com/reader/view/ [Referral]
power shell call .net system function (www.google.com) [Referral]
http://www.powershellcommunity.org/Blogs/ExternalBlogs.aspx [Referral]
http://www.google.com/ig?hl=en&source=iglk [Referral]
http://powershell.com/cs/content/TwitterGrid.aspx [Referral]
powershell functions parameters (www.google.com) [Referral]
http://pipes.yahoo.com/pipes/pipe.info?_id=uAmYy9xq3BGHcV361... [Referral]
.NET Attribute of function (www.google.com) [Referral]
http://powertwitter.me/ [Referral]
function .net (www.google.co.za) [Referral]
google rss powershell (www.google.com) [Referral]
http://powershellcommunity.org/Blogs/ExternalBlogs.aspx [Referral]
powershell functions param (www.google.com) [Referral]
vb.net function parameter as type (www.google.de) [Referral]
view attribute powershell (www.google.com) [Referral]
.net attribute parameter (www.google.de) [Referral]
powershell call function (www.google.nl) [Referral]
http://my.yahoo.com/ [Referral]
powershell function + Param (www.google.com) [Referral]
powershell function (www.google.com.hk) [Referral]
powershell what is "@" "&" (www.google.com) [Referral]
powershell functions parameters (www.google.com) [Referral]
.net system attribute function parameter (www.google.de) [Referral]
.net function parameter with systemattribute (www.google.de) [Referral]
http://www.google.nl/ig?hl=nl&t=1 [Referral]
powershell parameters (www.google.com) [Referral]
cache:nnhp-9DKCwQJ:powershellcommunity.org/Blogs/ExternalBlogs.aspx PowerShell credentialattribute advanced function (74.125.95.132) [Referral]
powershell functions parameters (www.google.com) [Referral]
vb.net decorate a function (www.google.com) [Referral]
aspx attribute function (www.google.com) [Referral]
powershell function true false (www.google.co.uk) [Referral]
powershell parameters (www.google.com) [Referral]
create power shell function parameters (www.google.com) [Referral]
call .net function powershell (www.google.com) [Referral]
powershell function (www.google.nl) [Referral]
vb.net pass parameter to powershell (www.google.co.uk) [Referral]
.net attribute parameters (www.google.com) [Referral]
powershell pipe functions parameter (www.google.com) [Referral]
powershell function parameter file (www.google.be) [Referral]
powershell parameter (www.google.co.kr) [Referral]
call function through attribute .NET (www.google.com) [Referral]
vb.net and powershell (www.google.co.uk) [Referral]
powershell functions parameters (www.google.com) [Referral]
powershell function parameters (www.google.com) [Referral]
Power Shell Function (www.google.ru) [Referral]
vb.net execute function in attribute (www.google.si) [Referral]
parameters for function .net (www.google.com) [Referral]
function parameters type .net (www.google.co.in) [Referral]
powershell parameters (www.google.be) [Referral]
vb.net attributes on parameter (www.google.com) [Referral]
powershell parameters (www.google.com) [Referral]
attribute for parameters funtion vb.net (www.google.co.in) [Referral]
powershell [Parameter()] (www.google.com) [Referral]
function pass \parameters powershell (www.google.pl) [Referral]
powershell function param() $True $False (www.google.nl) [Referral]
aspx .Attributes[ (www.google.ca) [Referral]
powershell functions parameters (www.google.com) [Referral]
what are .net function attributes (www.google.com) [Referral]
windows 7 I attribute (www.google.com) [Referral]
function parameter .net (www.google.com) [Referral]
func in attribute parameter (www.google.com) [Referral]
powershell function types (www.google.com.tr) [Referral]
http://www.netvibes.com/online_casinos [Referral]
powershell parameterized type (www.google.com) [Referral]
powershell parameters attributes (www.bing.com) [Referral]
powershell check pipe or param (www.google.com) [Referral]
types of function parameters .NET (www.google.co.in) [Referral]
c# .net function to powershell function (www.google.com) [Referral]
VB.Net decorating functions (www.google.com) [Referral]
powershell function param (hk.search.yahoo.com) [Referral]
http://www.netvibes.com/ [Referral]
calling a function with parameters in powershell (www.google.com.au) [Referral]
.net function attributes (www.google.com) [Referral]
call .net function in power shell (search.yahoo.com) [Referral]
vb.net adding power shell parameters (www.google.com.au) [Referral]
vb.net attribute parameters function (www.bing.com) [Referral]
how to call vb.net function on attribute (www.google.co.in) [Referral]
powershell function attribute (www.google.se) [Referral]
powershell function (www.bing.com) [Referral]
powershell create function (www.bing.com) [Referral]
powershell function (www.bing.com) [Referral]
powershell functions parameters (www.bing.com) [Referral]
powershell piping ".net" (www.bing.com) [Referral]
System.Management.Automation.ArgumentTypeConverterAttribute (www.bing.com) [Referral]
.net functions attributes (www.google.es) [Referral]
.net attributes parameters (www.google.lv) [Referral]
powershell function parameters (search.yahoo.com) [Referral]
SharePoint Powershell passing parameters (www.bing.com) [Referral]
http://delicious.com/Jaykul?utm_source=feedburner&utm_medium... [Referral]
powershell function parameters (www.bing.com) [Referral]
http://www.google.com/reader/view/?hl=en&tab=wy [Referral]
http://www.google.com/reader/public/atom/user/13309556466516... [Referral]
type converter powershell parameter (www.google.nl) [Referral]
powershell attributes (www.google.com) [Referral]
types of parameters in .NET (www.google.co.in) [Referral]
aspx function with parameters (www.google.com.pe) [Referral]
vb.net in attribute parameter (www.google.com) [Referral]
powershell function parameters (www.google.com) [Referral]
passing parameter to function+powershell (www.google.com.mx) [Referral]
powershell function (www.bing.com) [Referral]
powershell true false function (www.google.com) [Referral]
powershell get functions .net (www.google.de) [Referral]
powershell credential parameter (www.google.com) [Referral]
powershell function parameter type (www.google.com) [Referral]
powershell call function with parameters +param (www.google.co.uk) [Referral]
credential parameter function powershell (www.google.com) [Referral]
params powershell (www.google.com) [Referral]
powershell function parameters (www.google.no) [Referral]
param params powershell (www.google.fr) [Referral]
call powershell function from VB.NET (www.bing.com) [Referral]
powershell 2 function param (www.google.com) [Referral]
powershell credential attribute (www.google.ca) [Referral]
powershell asp.net adding parameter (www.google.se) [Referral]
powershell execute .net functions (www.google.ro) [Referral]
powershell call .net functions (www.google.com) [Referral]
powershell call function (www.google.de) [Referral]
powershell function "&" (www.google.com.hk) [Referral]
aspx <% %> Function with parameters (www.google.ca) [Referral]
vb.net function attributes (search.yahoo.com) [Referral]
http://assist.babylon.com/babylonassista/dnsassist/main?acti... [Referral]
http://www.baidu.com/s?bs=powershell+%B5%F7%D3%C3%BA%AF%CA%F... [Referral]
powershell function attribute (www.bing.com) [Referral]
powershell funtion (www.bing.com) [Referral]
powershell function attributes (www.bing.com) [Referral]
.net attribute params (www.google.co.uk) [Referral]
powershell parameters vb.net (www.google.co.il) [Referral]
function parameter attribute vb.net (www.google.com.pk) [Referral]
http://guide.opendns.com/controller.php?url=powershell+funct... [Referral]
funtion powershell (www.google.fr) [Referral]
powershell gi function (www.google.at) [Referral]
Passing parameters in Powershell through VB.net (www.google.com) [Referral]
powershell parameter attribute (www.google.com) [Referral]
powershell function parameters (www.google.com) [Referral]
attributes powershell (www.google.com) [Referral]
powershell parameters function passing .net objects (www.bing.com) [Referral]
powershell function (www.bing.com) [Referral]
get function params in vb .net (www.google.com) [Referral]
.net attributes in powershell (www.google.co.uk) [Referral]
powershell parameter attribute (www.google.com) [Referral]
powershell+php+pass params (www.google.co.uk) [Referral]
powershell function with params (www.google.co.uk) [Referral]
passing parameters pipe powershell function (www.google.com) [Referral]
powershell function string param (de.altavista.com) [Referral]
powershell how to see attributes (www.google.com.tr) [Referral]
http://www.diigo.com/bookmark/http%3A//www.nivot.org/2009/10... [Referral]
ArgumentTransformationAttribute (www.google.de) [Referral]
vb.net powershell parameters (www.google.com) [Referral]
powershell passing parameters to function (www.google.co.uk) [Referral]
windows 7 powershell attrib (www.google.com) [Referral]
powershell function referral (www.google.fr) [Referral]
.net functions in powershell (www.google.com) [Referral]
.net shell function (www.bing.com) [Referral]
http://yandex.ru/yandsearch?text=c3+attribute+%D1%82%D1%83%D... [Referral]
.net call function attributes (www.google.co.uk) [Referral]
powershell function cache -velocity (www.google.com) [Referral]
powershell param pipe (www.google.com) [Referral]
http://www.baidu.com/s?wd=vb+Parameters+.net [Referral]
powershell 2.0 parameter attributes (www.google.co.uk) [Referral]
powershell blogs (www.bing.com) [Referral]
vb.net function parameter attributes (www.google.be) [Referral]
powershell .net parameter (www.google.ca) [Referral]
powershell pipe function parameter (www.google.nl) [Referral]
powershell function parameters (www.google.co.uk) [Referral]
vb.net parameter attribute (www.google.com.my) [Referral]
powershell function parameter (www.google.co.uk) [Referral]
Func attribute .net (www.google.com) [Referral]
powershell passing parameters pipe (www.bing.com) [Referral]
.net pass parameters to attributes (www.google.bg) [Referral]
powershell function parameters (www.bing.com) [Referral]
sharepoint powershell FBA credentials (www.bing.com) [Referral]
powershell function as a parameter (www.bing.com) [Referral]
powershell 2.0 "function parameters" (www.google.com) [Referral]
"powershell 2" param function (www.google.com) [Referral]
pass net time \\ to powershell (www.bing.com) [Referral]
powershell ArgumentTransformationAttribute (www.bing.com) [Referral]
call powershell from vb.net (www.google.com) [Referral]
http://www.baidu.com/s?bs=PowerShell+%BD%C5%B1%BE%C0%FD%D7%D... [Referral]
powershell get attributes (www.bing.com) [Referral]
powershell credential function (www.bing.com) [Referral]
vb.net powershell passing parameters (www.google.com) [Referral]
powershell Parameterattribute (www.google.com) [Referral]
powershell "net time" (www.google.com) [Referral]
System.Management.Automation.ArgumentTypeConverterAttribute (www.google.com) [Referral]
http://www.google.nl/#num=30&hl=en&newwindow=1&q=powershell+... [Referral]
call powershell with parameter in VB.NET (www.google.com) [Referral]
powershell function parameters (www.google.com) [Referral]
.NET function parameter (www.bing.com) [Referral]
powershell call .net functions (www.google.com) [Referral]
TypeConverter attribute powershell (www.google.com) [Referral]
vb.net shell parameter (www.google.com.tr) [Referral]
http://delicious.com/Jaykul/powershell?page=2 [Referral]
powershell function vb pass parameters (www.google.com) [Referral]
powershell parameter types (www.google.hu) [Referral]
http://delicious.com/Jaykul/PowerShell?page=2 [Referral]
powershell "function attributes" (www.google.com) [Referral]
powershell "parameter attribute" (www.google.com) [Referral]
powershell parameter types (www.google.com) [Referral]
PowerShell advanced functions parameters (www.bing.com) [Referral]
powershell pass objects to functions (www.google.com) [Referral]
passing powershell param with c# (www.google.com) [Referral]
.net functions powershell (www.google.cz) [Referral]
powershell pipe parameter function (www.google.fr) [Referral]
powershell + passing parameters to .net functions (www.bing.com) [Referral]
powershell function attribute (cn.bing.com) [Referral]
powershell function mit attribut aufrufen (www.google.de) [Referral]
pipe function in powershell (www.google.com) [Referral]
typeconverter powershell (www.google.com) [Referral]
how to call .NET functions in powershell (www.google.es) [Referral]
call powershell from asp.net (www.google.co.uk) [Referral]
powershell calling functions (www.google.com) [Referral]
poweshell in c# param function (www.google.com) [Referral]
powershell functions parameters (www.bing.com) [Referral]
how to call a function with parameters in vb (www.bing.com) [Referral]
powershell parameter attribute (www.google.com.au) [Referral]
powershell attrib (www.google.dk) [Referral]
powershell pass function as argument to a function (www.google.com) [Referral]
powershell functions attributes (www.google.bg) [Referral]
System.Management.Automation.ArgumentTypeConverterAttribute (www.bing.com) [Referral]
powershell passing function to a function (www.google.com.au) [Referral]
how to call powershell function with no params (www.google.com) [Referral]
ArgumentTransformationAttribute (www.google.com) [Referral]
powershell parameters ".net" (www.bing.com) [Referral]
c# attributes on functions cache (www.google.se) [Referral]
powershell "passing function" (www.google.ch) [Referral]
powershell param pipe (www.google.de) [Referral]
+powershell+".net" (www.google.com) [Referral]
powershell Func<> (www.google.com) [Referral]
powershell attribute (www.google.com) [Referral]
powershell function param (www.google.se) [Referral]
powershell WCF DataContractJsonSerializer jaykul (www.bing.com) [Referral]
.net fuction compute (www.bing.com) [Referral]
powershell attributes (www.google.de) [Referral]
powershell function parameters (www.google.ca) [Referral]
http://www.google.com.pk/ig?hl=en (www.google.com.pk) [Referral]
powershell argument transformation windows.forms (www.google.be) [Referral]
vb.net functon attributes function? (www.google.com) [Referral]
vb.net powershell pipe (www.google.ca) [Referral]
http://www.powershell-scripting.com/index.php?option=com_joo... [Referral]
powershell "function as a parameter" (www.google.com) [Referral]
powershell function parameter xml (www.google.com) [Referral]
"how to" powershell "function attributes" (www.google.com) [Referral]
calling powershell from c# with parameters (www.bing.com) [Referral]
ArgumentTransformationAttribute (www.google.com) [Referral]
vb.net function attribute list arguments (www.google.com) [Referral]
credential function param powershell (www.google.co.uk) [Referral]
powershell attrib (www.google.es) [Referral]
parameter function powershell (www.google.fr) [Referral]
powershell pass AD attribute to function (www.google.com) [Referral]
Get-Credential powershell vb.net (www.google.com.br) [Referral]
passing .net objects to powershell functions (www.bing.com) [Referral]
powershell comboxbox attributes functions (www.bing.com) [Referral]
call powershell from vb.net (www.google.com) [Referral]
c# attribute func (www.google.com) [Referral]
.net attribute parameter types (www.google.com) [Referral]
.net set Func as attribute parameter (www.google.com) [Referral]
powershell .passing net object parameters (www.google.es) [Referral]
howto vb.net powershell (www.google.de) [Referral]
.net attribute func (www.google.com) [Referral]
PowerShell+.net (www.google.co.uk) [Referral]
vb.net parameter (hk.search.yahoo.com) [Referral]
call function with param in powershell (www.bing.com) [Referral]
how to pass function in atrribute .NET (www.google.ru) [Referral]
ArgumentTransformationAttribute change in 2.0 (www.google.co.uk) [Referral]
func .net (www.google.com) [Referral]
Attrib arguments (www.google.co.uk) [Referral]
"net time \\www.google.com" (www.google.com.au) [Referral]
http://www.baidu.com/s?bs=function&f=8&wd=.net+function [Referral]
http://www.google.pt/ [Referral]
POWERSHELL parameter (www.google.ca) [Referral]
powershell "function as a parameter" (www.google.com) [Referral]
function parameter vb net (www.google.co.th) [Referral]
.net attribute takes func (www.google.com) [Referral]
attributes for arguments vb.net (www.google.it) [Referral]
.net attribute (www.google.com) [Referral]
func powershell (www.google.co.uk) [Referral]
+powershell transform parameters (www.google.com) [Referral]
ink parameters (www.google.pl) [Referral]
powershell .net objects passing (www.google.ca) [Referral]
vb.net parameter attributes (www.google.com.au) [Referral]
powershell + .net (www.bing.com) [Referral]
what is powershell modules (www.lijit.com) [Referral]
http://powershell.com/cs/forums/p/2716/3623.aspx [Referral]
powershell function parameters .net object (www.bing.com) [Referral]
calling powershell from asp.net (www.bing.com) [Referral]
bing http parameters list (www.bing.com) [Referral]
argumenttransformationattribute (www.google.com) [Referral]
parameter in powershell from c# (www.bing.com) [Referral]
powershell "pass function as argument" (www.google.com) [Referral]
advanced functions powershell (www.lijit.com) [Referral]
power shell in sharepoint (search.yahoo.com) [Referral]
VB NET PowerShell (tw.search.yahoo.com) [Referral]
powershell parameters (www.google.com) [Referral]
"powershell 2" function arguments (www.google.se) [Referral]
http://www.google.com/ [Referral]
pipe credentials to powershell script (www.bing.com) [Referral]
+Powershell function parameters (www.bing.com) [Referral]
vb net su parameters (www.google.nl) [Referral]
use attributes in powershell function (www.google.com) [Referral]
"function attributes" .net (www.bing.com) [Referral]
gi powershell (www.bing.com) [Referral]
powershell funtion (www.bing.com) [Referral]
parameter attributes in powershell (www.bing.com) [Referral]
c# send parameters to powershell function (www.google.ru) [Referral]
http://www.google.co.in/ [Referral]
powershell view attribute (www.bing.com) [Referral]
powershell function parameter pipe (www.bing.com) [Referral]
powershell function parameter without value (www.bing.com) [Referral]
call powershell function vb (www.google.com) [Referral]
function as parameters powershell (www.bing.com) [Referral]
Comments are closed.