$varMaDate = get-date -format "yyyy_MM_dd_-_HH_mm_ss" add-pssnapin Citrix.* -erroraction silentlycontinue $varCheminRepertoireScript = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition) #write-host $varCheminRepertoireScript $currentScriptName = $MyInvocation.MyCommand.Name #Récupération du nom du script en cours #On ne prend que le nom du script sans l'extention. Pour cela on chercher la position d'un point en partant de la droite et on prend tout ce qui est à sa gauche $currentScriptName = $currentScriptName.substring(0,$($currentScriptName.lastindexofany("."))) #write-host $currentScriptName $outpath = "$varCheminRepertoireScript\$($currentScriptName)_$($varMaDate)_Export.txt" #write-host $outpath $xaappsessionslist = Get-XASession | Select AccountName, ServerName | Where-Object {$_.AccountName.Length -igt 0} | sort-object -property AccountName, ServerName | format-table $xaappsessionslist | out-file $outpath