#Author: Daniel Mulroy #Company: GEM Software LTD #Script Purpose: The script makes a copy of the Ejob database and sends it of a compressed zip file. It then send that file to a GEM support account for further investigation. #Copyright: The script was created and is supported by GEM Software Ltd. Changes to the script is prohibited. #Contact Details:Danny.Mulroy@gem-software.net if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } Stop-service DataSyncService Compress-Archive -Path "C:\Users\$env:USERNAME\AppData\Local\GEM Software\Panda Cub\f31160d8-363d-4d6c-abe3-3cdfd5691a92\Data\EJOB.accdb" -DestinationPath "C:\Users\$env:USERNAME\AppData\Local\GEM Software\Panda Cub\f31160d8-363d-4d6c-abe3-3cdfd5691a92\Data\" $date = (Get-Date).ToString("ddMMyyyy") Rename-Item -Path "c:\Users\$env:USERNAME\AppData\Local\GEM Software\Panda Cub\f31160d8-363d-4d6c-abe3-3cdfd5691a92\Data\.zip" -NewName "EJOB_$date.zip" Start-Sleep -s 10 #create COM object named Outlook $Outlook = New-Object -ComObject Outlook.Application #create Outlook MailItem named Mail using CreateItem() method $Mail = $Outlook.CreateItem(0) #State path to the file you want to send $file = "C:\Users\$env:USERNAME\AppData\Local\GEM Software\Panda Cub\f31160d8-363d-4d6c-abe3-3cdfd5691a92\Data\EJOB_$date.zip" #add properties as desired $Mail.To = "support@gem-software.net" $Mail.Subject = "Ejob Database" $Mail.Body = "testing" $Mail.Attachments.Add($file) #send message $Mail.Send() $Outlook.Quit() [System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook) | Out-Null #Removes the zip file that was created Remove-Item "C:\Users\$env:USERNAME\AppData\Local\GEM Software\Panda Cub\f31160d8-363d-4d6c-abe3-3cdfd5691a92\Data\*.zip"