classes/VIServer.ps1
class VexaVIServer { [string] $Name [string] $InstanceUuid [version] $Version [int] $Build [string] $OsType [VexaVIServerAdvSettings] $AdvancedSettings = [VexaVIServerAdvSettings]::new() VexaVIServer() {} VexaVIServer($Conn) { $this.Name = $Conn.Name $this.InstanceUuid = $Conn.InstanceUuid $this.Version = $Conn.Version $this.Build = $Conn.Build $this.OsType = $Conn.ExtensionData.Content.About.OsType if ($Conn.GetType().Name -eq "VIServerImpl") { # Construct class using PowerCLI Get-View data $AdvSettings = Get-View -Id $Conn.ExtensionData.Content.Setting $this.AdvancedSettings = [VexaVIServerAdvSettings]::new($AdvSettings) } else { # Reserialize object from Import-Clixml data $this.OsType = $Conn.OsType $this.AdvancedSettings = [VexaVIServerAdvSettings]::new($Conn.AdvancedSettings) } } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") -and -not ($_.Name -eq "AdvancedSettings") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaVIServerAdvSettings { [string] $mail_sender [string] $mail_smtp_password [int] $mail_smtp_port [string] $mail_smtp_server [string] $mail_smtp_username [int] $event_batchsize [int] $event_maxAge [bool] $event_maxAgeEnabled [int] $task_batchsize [int] $task_maxAge [bool] $task_maxAgeEnabled VexaVIServerAdvSettings() {} VexaVIServerAdvSettings($AdvSettings) { if ($AdvSettings.Setting) { # Construct class using PowerCLI Get-View data $Lookup = @{} $AdvSettings.Setting.GetEnumerator().ForEach({$Lookup.$($_.Key) = $_.Value}) $this.mail_sender = $Lookup."mail.sender" $this.mail_smtp_password = $Lookup."mail.smtp.password" $this.mail_smtp_port = $Lookup."mail.smtp.port" $this.mail_smtp_server = $Lookup."mail.smtp.server" $this.mail_smtp_username = $Lookup."mail.smtp.username" $this.event_batchsize = $Lookup."event.batchsize" $this.event_maxAge = $Lookup."event.maxAge" $this.event_maxAgeEnabled = $Lookup."event.maxAgeEnabled" $this.task_batchsize = $Lookup."task.batchsize" $this.task_maxAge = $Lookup."task.maxAge" $this.task_maxAgeEnabled = $Lookup."task.maxAgeEnabled" } else { # Reserialize object from Import-Clixml data $this.mail_sender = $AdvSettings.mail_sender $this.mail_smtp_password = $AdvSettings.mail_smtp_password $this.mail_smtp_port = $AdvSettings.mail_smtp_port $this.mail_smtp_server = $AdvSettings.mail_smtp_server $this.mail_smtp_username = $AdvSettings.mail_smtp_username $this.event_batchsize = $AdvSettings.event_batchsize $this.event_maxAge = $AdvSettings.event_maxAge $this.event_maxAgeEnabled = $AdvSettings.event_maxAgeEnabled $this.task_batchsize = $AdvSettings.task_batchsize $this.task_maxAge = $AdvSettings.task_maxAge $this.task_maxAgeEnabled = $AdvSettings.task_maxAgeEnabled } } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } |