Playing with the new class function in PowerShell v5, and I'm trying to get my head around if we can put methods into classes.

I've tried the below and played about with it for a bit, but haven't been having luck.

class Server { [string]$computerName = "192.168.0.200" [bool]$ping = (Test-Connection -ComputerName $computerName).count } $1 = [server]::new() $1.computerName = "blah"

I've tried with manually entering a computer name via setting the property, but then I assumed you'd need it at object creation

$1 = [server]::new($computerName = "192.168.0.200")

Exceptions I'm getting are

[ERROR] Exception calling ".ctor" with "0" argument(s): "Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the [ERROR] command again." [ERROR] At D:\Google Drive\Projects\VSPowerShell\DiscoveryFramework\DiscoveryFramework\DiscoveryFramework\class.ps1:12 char:1 [ERROR] + $1 = [server]::new() [ERROR] + ~~~~~~~~~~~~~~~~~~~~ [ERROR] + CategoryInfo : NotSpecified: (:) [], MethodInvocationException [ERROR] + FullyQualifiedErrorId : ParameterBindingValidationException [ERROR] [DBG]: PS C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> [DBG]: PS C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> $1 Server [DBG]: PS C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> $1.gettype() Server

Full exception link from $error is on http://pastebin.com/WtxfYzb5

Got a bit further used $this.prop, but you cant initiate the constructor with your own parameters.