July 2018
Beginner
552 pages
13h 18m
English
To properly denote the output of your cmdlet, it is recommended to set the OutputType accordingly. This is, first and foremost, helpful to support IntelliSense and tab completion for the objects that you return:
function Get-ContosoFile{ [CmdletBinding()] [OutputType('System.IO.FileInfo')] param ( [string] $Path )}Get-ContosoFile | Where-Object -Property # TAB or Ctrl-Space here
When using your own objects, consider adding a type to them. Not only will this make it easier to discern them with the -is operator later on, it will also make it possible to format them properly. We will revisit that example when we examine the architecture of a module:
function Get-Bob{ [CmdletBinding()] [OutputType('Contoso.Bob')] param ( ) [PSCustomObject]@{ ...Read now
Unlock full access