hi,<\/p>\n
I have exported disconnected RDP sessions from a server.<\/p>\n
Just trying to figure out how to email those users individually and list of managers<\/p>\n
The CSV header is SessionID that has the email address.<\/p>\n
See script below<\/p>\n
& ‘C:\\Scripts\\MASTER-RDP SESSIONS.ps1’ | Where-Object {($.SessionID = $<\/em>.SessionID + “@domain.com<\/span>”)} |export-csv -NoTypeInformation -Path “C:\\temp\\InactiveSessions.csv”<\/p>\n #import<\/span> Report<\/p>\n $report = “C:\\temp\\InactiveSessions.csv” $Subject = “DISCONNECTED SERVER SESSIONS<\/strong>” + $today Send-MailMessage -To $emailTo -From $emailFrom -SmtpServer $smtpServer -Subject $Subject -Attachments $report<\/p>\n foreach ($SessionID IN $UserList) { hi,<\/p>\n I have exported disconnected RDP sessions from a server.<\/p>\n Just trying to figure out how to email those users individually and list of managers<\/p>\n The CSV header is SessionID that has the email address.<\/p>\n See script below<\/p>\n & ‘C:\\Scripts\\MASTER-RDP SESSIONS.ps1’ | Where-Object {($.SessionID = $<\/em>.SessionID + “@domain.com<\/span>”)} |export-csv -NoTypeInformation -Path “C:\\temp\\InactiveSessions.csv”<\/p>\n #import<\/span> Report<\/p>\n $report = “C:\\temp\\InactiveSessions.csv” $Subject = “DISCONNECTED SERVER SESSIONS<\/strong>” + $today Send-MailMessage -To $emailTo -From $emailFrom -SmtpServer $smtpServer -Subject $Subject -Attachments $report<\/p>\n foreach ($SessionID IN $UserList) { Welcome<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n<\/a>}<\/h1>\n
\n$UserList = Import-Csv $report<\/p>\n<\/a>Setup email parameters<\/h1>\n
\n$priority = “Normal”
\n$smtpServer = “xxxx.xxxx.local”
\n$emailFrom = “[email protected]<\/a>”
\n$emailTo = “Managers”
\n$EmailBody = “Disconnected Server Sessions”<\/p>\n
\nSend-MailMessage -To $SessionID -From $emailFrom -SmtpServer $smtpServer -Subject $Subject -Body $EmailBody}<\/p>","upvoteCount":3,"answerCount":3,"datePublished":"2020-06-10T17:29:21.000Z","author":{"@type":"Person","name":"spiceuser-y2pq8","url":"https://community.spiceworks.com/u/spiceuser-y2pq8"},"suggestedAnswer":[{"@type":"Answer","text":"<\/a>}<\/h1>\n
\n$UserList = Import-Csv $report<\/p>\n<\/a>Setup email parameters<\/h1>\n
\n$priority = “Normal”
\n$smtpServer = “xxxx.xxxx.local”
\n$emailFrom = “[email protected]<\/a>”
\n$emailTo = “Managers”
\n$EmailBody = “Disconnected Server Sessions”<\/p>\n
\nSend-MailMessage -To $SessionID -From $emailFrom -SmtpServer $smtpServer -Subject $Subject -Body $EmailBody}<\/p>","upvoteCount":3,"datePublished":"2020-06-10T17:29:21.000Z","url":"https://community.spiceworks.com/t/powershell-to-email-individual-users-in-a-csv/765615/1","author":{"@type":"Person","name":"spiceuser-y2pq8","url":"https://community.spiceworks.com/u/spiceuser-y2pq8"}},{"@type":"Answer","text":"