Je suis en train de développer un script mais j’ai du mal a debuger l’erreur que j’obtiens.
Le but etant d’envoyer un message aux personnes actuellement connectées a une application donnée.
Voici mon script :
Set ArgObj = WScript.Arguments
AppName = ArgObj(0)
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
WScript.Echo "Application Name: " & AppName
Set oFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
oFarm.Initialize(1)
For each oApplication in oFarm.Applications
oApplication.LoadData(1)
If oApplication.AppName = "Toto" Then
For Each oSession in oApplication.Sessions
ServerName = oSession.ServerName
SessionID = oSession.SessionID
UserName = oSession.Username
ClientName = oSession.ClientName
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
SessionState = oSession.SessionState
voici ton script corrigé et fonctionnel ( testé sur xenapp 5/2008 )
j’ai rajouté la detection de connexion afin de ne pas avoir d’erreur sur les user dont l’etat est déconnecté
Send message to spÈcific application users
CScript //nologo sendMessage.wsf ApplicationName
'SendMessage
'
'
Set ArgObj = WScript.Arguments
AppName = ArgObj(0)
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
Set oFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
oFarm.Initialize(1)
For each oApplication in oFarm.Applications
oApplication.LoadData(1)
If oApplication.AppName = AppName Then
wscript.echo "Application search : OK"
For Each oSession in oApplication.Sessions
ServerName = oSession.ServerName
SessionID = oSession.SessionID
UserName = oSession.Username
ClientName = oSession.ClientName
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
SessionState = oSession.SessionState
wscript.echo UserName & "session state: "& SessionState
If UserName "" and SessionState = 1 Then
wscript.echo "User " & UserName & " on " & ServerName & " with the session ID: " & SessionID