Posts

Showing posts from May, 2023

Notify via Email on user login with Public IP with Event ID 21 Using PowerShell script

Image
PowerShell script for Windows Server. This script is used for fire and Email notification on any user login via Public IP. Steps: 1. Save the script with the name EmailNotification.ps1. 2. Create a Basic Task via Task Scheduler. Enter Name for Task. 3. Select the Trigger option "When a specific event is logged" 4. Select option as below. 5. On Action Select "Start a specific program" and browse the EmailNotification.ps1 file. 6. Save the task. Script:  # Define the SMTP server details and user credentials $smtpServer = "SMTP server" # SMTP.GMAIL.COM $smtpUsername = "SMTP username" $smtpPassword = "password for authentication" $smtpSecurePassword = ConvertTo-SecureString -String $smtpPassword -AsPlainText -Force $smtpCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $smtpUsername, $smtpSecurePassword $from = "from@example.com" $to = "to@example.com" # Define Regex ...

Decrypt the password from RDCMan.exe using PowerShell Script.

Decrypt the password from RDCMan.exe using PowerShell Script.   The script is used for retrieving the password from RDCMan.exe. The script is only working within the profile from which the original .rdg file was generated. Because The string is encoded with the local user profile that is used to set the password in the RDG file. Therefore the string cannot be decrypted from another user account than yours.  Comments: <# 1. Rename the RDP.rdg file to RDP.xml in the original folder or you may copy it to a different location. 2. Rename the RDCMan.exe to RDCMan.dll in the C:\Temp folder in the original folder or you may copy it to a different location. #>  Import-Module 'Path\to\RDCMan.dll'  $EncryptionSettings = New-Object -TypeName RdcMan.EncryptionSettings  $xml = [xml](Get-Content "Path\to\RDP.xml") # Path to RDP.xml file.  $passwords = Select-Xml -Xml $xml -XPath "//password"  $usernames = Select-Xml -Xml $xml -XPath "//userName"  forea...