What is [cmdletbinding()] and how does it work?
CmdletBinding, Parameter etc. are special attribute classes that scripters can use to define PowerShell's behavior, e.g. make a function an Advanced function with Cmdlet capabilites.
When you call them via e.g. [CmdletBinding()]
you initialize a new instance of the class.
Read more about the CmdletBindingAttribute class at: MSDN
Read more about the ParameterAttribute class at: MSDN
More about Attribute classes here and here
Generally speaking, CmdletBinding is what makes a function into an Advanced function. Putting it at the top of a script makes the script an "advanced" script. Functions and scripts are much the same, where the script file name is equivalent to the function name and the script content is equivalent to the scriptblock section of a function.
CmdletBinding attributes give you control over function capabilities, such as adding Confirm and WhatIf support (via SupportsShouldProcess), Disable parameters positional binding, and so on.