< Back

Get-Donut

Sat Jan 18, 2020 9:42 am

NAME Get-Donut



SYNOPSIS

Retrieves Donuts to show some fundamental PowerShell concepts.





SYNTAX

Get-Donut [[-Identity] <String>] [<CommonParameters>]





DESCRIPTION

The function retrieves Donut-Objects (PSCustom-Objects) that have been created with

New-Donut.



This is a nice way to get familiar with the object-oriented pipeline in PowerShell.



The Donut module showes following concepts:

- Writing functions (New-Donut, Set-Donut, Get-Donut)

- Use this functions to create a simple script-module (Learn-PowerShell-with-Donuts)



The functions demonstrate following concepts:

- Error Handling with try/catch

- Object-oriented pipeline



Like any other Get-Cmdlet this does not make any changes on your system.

In the background it retrieves the Donut-Objects from a global variable.





PARAMETERS

-Identity <String>

Specifies the Identity of the Donut. Each Donut has an unique identifier.



Required? false

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





This function was created and tested on macOS using Visual Studio Code (VS Code).

Therefore it is based on the functionality of .NET Core.



I formed this idea during a travel in ICE from Frankfurt to Nuremberg. We had some

technical problems on the train and stopped for a while. No Dunkin Donut was nearby.

So this code was born to create at least some virtual Donuts.



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-Donut -Identity 5



Outputs Donut 5









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-Donut | Where Style -eq 'Glazed' | Set-Donut -Style 'Boston Creme'



Turns Glazed Donuts into delicous Boston Creme Donuts.











RELATED LINKS

http://github.com/rfc821/Learn-PowerShell-with-Donuts