Reader small image

You're reading from  Mastering PowerShell Scripting - Fourth Edition

Product typeBook
Published inJun 2021
PublisherPackt
ISBN-139781800206540
Edition4th Edition
Right arrow
Author (1)
Chris Dent
Chris Dent
author image
Chris Dent

Chris Dent is an automation specialist with deep expertise in the PowerShell language. Chris is often found answering questions about PowerShell in both the UK and virtual PowerShell user groups. Chris has been developing in PowerShell since 2007 and has released several modules over the years.
Read more about Chris Dent

Right arrow

Classes for parameters

PowerShell includes several attributes that you can use on parameters. Each of these classes inherits from another .NET type. The classes include:

  • Argument transformation attributes
  • Validation attributes
  • Classes for use with ValidateSet

You can implement each of these using classes in PowerShell.

Argument transformation attributes are used to test and potentially change the value being assigned to a variable before the assignment completes.

Argument-transformation attribute classes

An argument-transformation attribute is used to convert the value of an argument for a variable. The transformation operation is carried out before PowerShell completes the assignment to the variable, giving the opportunity to avoid type mismatch errors.

You can add argument-transformation attributes to any variable, including parameters in functions and scripts and properties in classes.

Classes for argument transformation must...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering PowerShell Scripting - Fourth Edition
Published in: Jun 2021Publisher: PacktISBN-13: 9781800206540

Author (1)

author image
Chris Dent

Chris Dent is an automation specialist with deep expertise in the PowerShell language. Chris is often found answering questions about PowerShell in both the UK and virtual PowerShell user groups. Chris has been developing in PowerShell since 2007 and has released several modules over the years.
Read more about Chris Dent