Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created March 11, 2016 01:21
Show Gist options
  • Save PlagueHO/47be0d4ad65dd76a06d7 to your computer and use it in GitHub Desktop.
Save PlagueHO/47be0d4ad65dd76a06d7 to your computer and use it in GitHub Desktop.
Creating an ICloneable class in PowerShell, with the Clone method implemented.
class Car:ICloneable {
[Object] Clone () {
$NewCar = [Car]::New()
foreach ($Property in ($this | Get-Member -MemberType Property))
{
$NewCar.$($Property.Name) = $this.$($Property.Name)
} # foreach
return $NewCar
} # Clone
[String] $Make
[String] $Model
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment