< Back

Set-Donut

Sat Jan 18, 2020 9:42 am

NAME Set-Donut



SYNOPSIS

Modifies Donuts to show some fundamental PowerShell concepts.





SYNTAX

Set-Donut [-Identity] <String> [-Style] <String> [-Force] [<CommonParameters>]





DESCRIPTION

The function is one possible way to modify Donut-Objects (PSCustom-Objects).

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



Welcome to the Donut shop!



******** Note that the baker has following business hours ********

Monday - Saturday

8:00 am - 3:00 pm



Outside this business hours you maye receive a PowerShell

exeption when trying to modify donuts.



Opened on public holidays!

************************************************************************



The Donut module showes following concepts:

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

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



The functions demonstrate following concepts:

- Functions

- Input Arrays into you scripts

- Error Handling with try/catch

- Object-oriented pipeline



Instead of other Cmdlets like New-ADUser this function does not make any changes on your system.

In the background it saves the Donut-Objects in a global variable.





PARAMETERS

-Identity <String>

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



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Style <String>

Sets the kind of Donut you want. Option are:

- Sugar

- Boston Creme

- Sprinkles

- Glazed

- Blue Sky

- Blueberry Crunch



Required? true

Position? 2

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-Force [<SwitchParameter>]

You may force the Donut baker to manipulate Donuts outside his business hours.



Required? false

Position? named

Default value False

Accept pipeline input? false

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:\\>Set-Donut -Identity 5 -Style 'Boston Creme'



Turns Donut 5 into a Boston Creme Donut.









-------------------------- 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