<# .SYNOPSIS .NOTES Version : 1.0 Author : Hubert CORNET Creation Date : Purpose/Change : .LINK https://www.tips-of-mine.fr .EXEMPLE .DESCRIPTION .PARAMETER .INPUTS .OUTPUTS .log> #> #---------------------------------------------------------[Initialisations]-------------------------------------------------------- # Définir l'action d'erreur pour continuer silencieusement $ErrorActionPreference = "SilentlyContinue" # Bibliothèques de fonctions requises #----------------------------------------------------------[Declarations]---------------------------------------------------------- # Version Script $sScriptVersion = "1.0" #Log File Info $sLogPath = "C:\Tmp" $sLogName = ".log" $sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName ## ReturnStates $returnStateOK = 0 $returnStateWarning = 1 $returnStateCritical = 2 $returnStateUnknown = 3 $Separateur = ":" $DataTexte = "" $str = "" #-----------------------------------------------------------[Functions]------------------------------------------------------------ #------------------------------------------------------------[Script]-------------------------------------------------------------- cls cd "C:\Program Files\Centreon NSClient++" $ValiableRetour = cmd /c nscp.exe sys -- --validate Microsoft --all Foreach ($ligne in $ValiableRetour) { If ($ligne.StartsWith("\Microsoft Dynamics AX Object Server")) { $ArrayA = $ligne.Split("\") $ArrayB = ($ArrayA[2]).Split($Separateur) #Write-Host $ArrayB[0] #Write-Host ($ArrayB[1].Substring(0,$ArrayB[1].Length-1)).substring(4) $DataTexte += "'"+$ArrayB[0]+"'="+($ArrayB[1].Substring(0,$ArrayB[1].Length-1)).substring(4)+" " If ($ArrayB[0] -eq "ACTIVE SESSIONS") { $str = "Nombre de sessions active : "+($ArrayB[1].Substring(0,$ArrayB[1].Length-1)).substring(4) } } } write-output "OK - $str" "|" $DataTexte exit $returnStateOK