Methode dispose
Résolu
jun_1393
Messages postés
32
Statut
Membre
-
jun_1393 Messages postés 32 Statut Membre -
jun_1393 Messages postés 32 Statut Membre -
bonjour je vais un exo en powershell ou j'ai un fichier json que je dois deserialiser et verifier si le li fichier json(Data contient bien quelque chose ou non. cependant la methode que j'ai fais marche pas merci de m'Aider
<# <# .DESCRIPTION Classe PC .EXAMPLE $pc = [Pc]::new() #> Class Pc { # Stuff [ValidateNotNullorEmpty()] [int32] $ip [ValidateNotNullorEmpty()] [String] $masque [ValidateNotNullorEmpty()] [String] $nom # Constructeur Pc ([int32] $ip, [String] $masque,[String] $nom ) { $this.ip = $ip $this.masque = $masque $this.nom = $nom } <# # Serialize donné en paramêtre et le sauvegarde dans un fichier avecc Static [Void] Serialize([Pc] $ordi, [String] $Data) { # Serialize le PC $ordi | ConvertTo-Json | Out-File "C:\Users\jean\Desktop\AUTOMTISATION\Data.json"} #> #Static methode [String] Serialize(){ return $this | ConvertTo-Json } #dserialize static [Pc] Deserialize([String] $DATA) { return [Pc] (Get-Content -Path "C:\Users\jean\Desktop\AUTOMTISATION\Data.json" |Out-String | ConvertFrom-Json) } #Méthode Dispose static [PC] DisposeDe([String] $nomLogiciel){ $ok = true $sofware = $nomLogiciel $installer = (Get-ItemProperty HKLM:\SOFTWARE\Windows\CurrentVersion\Uninstall | Where {$_.DisplayName -eq $sofware}) -ne $null if(-Not $installer){ $ok = false }else{ $ok = true; } return $ok } } }}