PowerShell 5.0 : Writing Class using PowerShell
Environment
- Windows Server 10 Tech Preview
- PowerShell 5.0 September Preview
Class
help about_Classes -ShowWindow |
This is all we need to as a beginners. But why PowerShell 5.0 has class - It's simply make DEV and IT Pro to make their deployment smoother and clear.
Demo
Class Classroom
{ #Properties [String]$Title = "Mr." [String]$FirstName = "Chendrayan" [String]$LastName = "Venkatesan" [String]$Role = "Trainer"
#Methods [Void] GetInfo() { $this.Title = $Title $this.FirstName = $FirstName $this.LastName = $LastName $this.Role = $Role } [Void] SetInfo([string]$t , [string]$fn , [string]$ln , [String]$r) { $this.Title = $t $this.FirstName = $Fn $this.LastName = $ln $this.Role = $r } } $Var1 = [Classroom]::New() $Var1 |