Powershell script for Shavlik protect 9.2, to produce and email a CSV of patch status #https://community.shavlik.com/docs/DOC-23761 Invoke-Sqlcmd -serverinstance localhost\sqlexpress -database Protect -query " SELECT DISTINCT patch.[QNumber] AS [QNumber], product.[Name] AS [Product Name], patchScan.[StartedOn] AS [ScanDate], installState.[Value] AS [Install state], machine.[Name] AS [Machine Name] FROM [Reporting].[PatchScan] AS patchScan INNER JOIN [Reporting].[AssessedMachineState] AS assessedMachineState ON assessedMachineState.[PatchScanId] = patchScan.[Id] INNER JOIN [Reporting].[Machine] AS machine ON machine.[LastAssessedMachineStateId] = assessedMachineState.[id] INNER JOIN [Reporting].[DetectedPatchState] AS detectedPatchState ON detectedPatchState.[AssessedMachineStateId] = assessedMachineState.[Id] INNER JOIN [Reporting].[Patch] AS patch ON detectedPatchState.[PatchId] = patch.[Id] INNER JOIN [Reporting].[InstallState] AS installState ON installState.[Id] = detectedPatchState.[InstallStateId] INNER JOIN [Reporting].[Product] AS product ON product.[Id] = detectedPatchState.[ProductId] LEFT OUTER JOIN [sys].[syslanguages] AS locale ON machine.[Language] = locale.[lcid] /* machine.[Language] is used to index into [sys].[syslanguages] */ WHERE ( detectedPatchState.[InstallStateId] = -1 OR /* Not recorded */ detectedPatchState.[InstallStateId] = 0 OR /* Warning */ detectedPatchState.[InstallStateId] = 1 OR /* Note */ detectedPatchState.[InstallStateId] = 2 OR /* Informational */ detectedPatchState.[InstallStateId] = 3 OR /* Installed */ detectedPatchState.[InstallStateId] = 3 OR /* Installed Patch */ detectedPatchState.[InstallStateId] = 4 /* Missing Patch */ ) ORDER BY product.[Name], machine.[Name] " | export-csv "$env:temp\patch_report-$((get-date).tostring("MMddyyyy")).csv" send-mailmessage -smtpserver "contoso-cas" -to "me@contoso.com" -from "$env:computername@contoso.com" -subject "Weekly Patch Report" -body "See attached for weekly patch report." -attachments "$env:temp\patch_report-$((get-date).tostring("MMddyyyy")).csv"