title: Powershell class implement get set property
body: <p>How can I implement a get/set property with PowerShell class?
  Please have a look on my example below:</p>
  <pre><code>Class TestObject
  {
    [DateTime]$StartTimestamp = (Get-Date)
    [DateTime]$EndTimestamp = (Get-Date).AddHours(2)
  
    [TimeSpan] $TotalDuration {
      get {
        return ($this.EndTimestamp - $this.StartTimestamp)
      }
    }
    
    hidden [string] $_name = 'Andreas'
    [string] $Name {
      get {
        return $this._name
      }
      set {
        $this._name = $value
      }
    }
  }
  
  New-Object TestObject
  </code></pre>