Link to home
Start Free TrialLog in
Avatar of michalek19
michalek19Flag for United States of America

asked on

Script to check SEP production and latest virus definitions

Hi

I have short powershell script that checks Symantec Endpoint Protection Antivirus Definition Dates and Production version. After executing this script I am getting output but the output is a little bit messy.
I would like to ask if anyone with PS experience can combine both line of scripts into one and generate clean output into CSV file and send via email.

Script:

Invoke-Command -ScriptBlock {Get-ItemProperty -Path "hklm:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion" -name productversion} -Computername $(Get-Content servers.txt)
Invoke-Command -ScriptBlock {Get-ItemProperty -Path "hklm:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate" -name LatestVirusDefsDate} -Computername $(Get-Content servers.txt)


The CSV file out put should contain only

PSComputerName      : FTC-WB(Server Name)
PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion
PRODUCTVERSION      : 14.2.1031.0100
PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate
LatestVirusDefsDate : 2019-06-17

PSComputerName      : lon-wg(Server Name)
PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion
PRODUCTVERSION      : 14.2.1031.0100
PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate
LatestVirusDefsDate    : 2019-06-18
Avatar of oBdA
oBdA

Can't test it at the moment, but try it like this:
$outFile = 'C:\Temp\symantec.csv'
Invoke-Command -Computername $(Get-Content servers.txt) -ScriptBlock {
	[PSCustomObject]@{
		ComputerName = $ENV:ComputerName
		ProductVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion" -Name ProductVersion
		LatestVirusDefsDate = Get-ItemProperty -Path "HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate" -Name LatestVirusDefsDate
	}
} | Select-Object -Property ComputerName, ProductVersion, LatestVirusDefsDate | Export-Csv -NoTypeInformation -Path $outFile


$sendMailMessageParams = @{
	To =          "recipient"
	From =        "sender"
	Subject =     "Symantec version"
	Body =        "See attachment"
	Attachments = $outFile
	SmtpServer =  "server"
}
				
Send-MailMessage @sendMailMessageParams

Open in new window

Avatar of michalek19

ASKER

The script is running fine but the out i would like to change a little bit.

I only want to see only this instead of the whole path and the versions

ComputerName      ProductVersion      LatestVirusDefsDate
FTC-WB                    14.2.1031.0100      6/17/2019
LON-WG           14.2.1031.0100      6/18/2019

Please check attachment.
Output-file.png
i want to add another script to your code to check whether SEP is managed or unmanaged. Can you help me with this, too?

i tried to add this but it doesn't work

$outFile = 'C:\Users\xxxx\Desktop\SEPDEV\symantec.csv'
Invoke-Command -Computername $(Get-Content servers.txt) -ScriptBlock {
      [PSCustomObject]@{
            ComputerName = $ENV:ComputerName
            ProductVersion = Get-ItemProperty -Path "HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion" -Name ProductVersion
            LatestVirusDefsDate = Get-ItemProperty -Path "HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate" -Name LatestVirusDefsDate
            UseManagementServer = Get-ItemProperty -Path "HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\LiveUpdate\" -UseManagementServer
 
      }
} | Select-Object -Property ComputerName, ProductVersion, LatestVirusDefsDate, UseManagementServer | Export-Csv -NoTypeInformation -Path $outFile
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your help