jjoz
asked on
Powershell for WIndows Server 2003 terminal server (send notification to "disconnected" user)
Hi All,
I'm wondering if it is possible to create a powershell script to run scheduled which checked for the current "Disconnected" user from Terminal server ?
so the script should / can check within x amount of days of disconnected session and then NET SEND the user or send the email to that user.
Any idea would be greatly appreciated.
Thanks.
I'm wondering if it is possible to create a powershell script to run scheduled which checked for the current "Disconnected" user from Terminal server ?
so the script should / can check within x amount of days of disconnected session and then NET SEND the user or send the email to that user.
Any idea would be greatly appreciated.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes that's why it is quite hard to choose which methods to send the notification with :-|
Email is the most appropriate one i think.
Email is the most appropriate one i think.
You can use msg.exe...
If you like 3rd party solutions then look at http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm for an utility called TSMSG.
If you like 3rd party solutions then look at http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm for an utility called TSMSG.
ASKER
Hi Arnold, yes I can install IIS and make it send email to my Exchange Server 2007.
THanks for the suggestion.
THanks for the suggestion.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ah Yes, thanks for the explanation Chris,
this is Windows Server 2003 so I'm going to be using PS 1.0
this is Windows Server 2003 so I'm going to be using PS 1.0
Then this is how a mail might be sent. Obviously the message text will need a bit more work than I've given it here ;)
Just make sure any antivirus you have isn't blocking SMTP (TCP Port 25) or the message send will fail.
Chris
$To = "WhateverUser@domain.com"
$From = "you@domain.com"
$Subject = "Get off my server!"
$Body = "Please log off..."
$SmtpServer = "yourExchangeServer"
# Create MailMessage
$MailMessage = New-object Net.Mail.MailMessage($To, $From, $Subject, $Body)
# Optional: Set the body to HTML
$MailMessage.IsBodyHTML = $True
# Create the SMTP Client
$SmtpClient = New-Object Net.Mail.SmtpClient($SmtpServer)
$SmtpClient.Send($MailMessage)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, thanks for the helps again Chris, I'll try that tomorrow in the office.
Cheers.
Cheers.
ASKER
I've just realized that Powershell 2.0 is already released in different name URL: http://www.microsoft.com/downloads/details.aspx?FamilyId=909bbcf1-bd78-4e03-8c83-69434717e551
I wonder if this can be used in Windows Server 2003 R2 SP2 x64 environment, Does anyone recommend it or not ?
I wonder if this can be used in Windows Server 2003 R2 SP2 x64 environment, Does anyone recommend it or not ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I haven't installed it on many of my servers simply because I do most work from my workstation. However, it's solid and will run perfectly well under Windows 2003.
Whether you install it on the server or a workstation, I recommend it. Lots of tweaks to make life easier for all of us (and we don't have to worry about compatibility between versions).
Chris
http://windowsitpro.com/article/articleid/15035/how-can-i-check-if-a-user-is-logged-on-via-terminal-server.html
You can then parse the data to extract the username and their status/idle time
Presumably you would have a map or a known username -> email address.
does the server have an IIS SMTP installed?
Dropping a properly formatted text file into the c:\inetpub\mailroot\pickup
Sending email from powershell:
http://www.searchmarked.com/windows/how-to-send-an-email-using-a-windows-powershell-script.php