After creating the PEM file (key file for SSH), put it in MyDocuments (remember the path)

Get the SSH connection example from the EC2 instance panel. Keep in mind the Example line

Create a PowerShell script with the following info, replacing the local path to the pem file and Example from EC2:

ssh -i "C:\Users\pathto\file-key.pem" admin@the-example.compute.amazonaws.com

Save the file and copy the path to it

Go to C:\Program Files\PowerShell\7.exe

right click and SEND TO/ DESKTOP

Go to desktop and find the shortcut

right click, properties

replace Target for:

"C:\Program Files\PowerShell\7\pwsh.exe" --NoExit "C:\Users\pathTo\script.ps1"

Now if you double click the desktop shortcut, the PowerShell terminal should appear and connected directly to your instance