Last time I wrote about Powershell script to collect the SQL data collector and WMI data collector . Today I would like share one more Powershell script to send an email alerts for collected data statistics and some other counter queries. 1. Create a DBARepository database and following tables there CREATE DATABASE [DBARepository] GO USE [DBARepository] GO CREATE TABLE [dbo].[SQLServerInstances]( [InstanceID] [smallint] IDENTITY(1,1) NOT NULL, [DBName] [varchar](100) NULL, [IsActive] [bit] NULL, [UserName] [nvarchar](200) NULL, [Password] [nvarchar](200) NULL, [ServerName] [varchar](100) NULL, [IsDataCollector] [bit] NOT NULL DEFAULT ((0)), [IsEmailAlert] [bit] NOT NULL DEFAULT ((0)), [IsIndexBackup] [bit] NOT NULL DEFAULT ((0)), [IsSQLObjectBackup] [bit] NOT NULL DEFAULT ((0)), [IsDatabaseObjectBackup] [bit] NOT NULL DEFAULT ((0)), [IsSchemaBackup] [bit] NOT NULL DEFAULT ((0)) ) ON [PRIMARY] GO CREATE TABLE [dbo].[EmailAlerts]( [AlertID] [smallint] IDENTITY(
Sometime before i shared a script to collect data for SQL Server and databases using a power-shell script. Now i am sharing a same but it is for WMI data collectors instead of SQL data, which used for reporting, alert and monitoring purpose for all the Servers. Let me share a script here. How to use? 1. Create a DBARepository database and following tables there. CREATE DATABASE [DBARepository] GO USE [DBARepository] GO CREATE TABLE [dbo].[WMIServers]( [InstanceID] [smallint] IDENTITY(1,1) NOT NULL, [ServerName] [varchar](100) NULL, [IsActive] [bit] NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[WMICollectors]( [WMIID] [smallint] IDENTITY(1,1) NOT NULL, [WMIName] [varchar](100) NULL, [WMIItems] [varchar](4000) NULL, [PostExecScript] [varchar](4000) NULL, [IsActive] [bit] NULL, [Schedule] [varchar](30) NULL, [Occurrence] [smallint] NULL, [StartDate] [datetime] NULL, [LastRun] [datetime] NULL, [NextRun] [datetime] NULL, [InstanceIDs] [varchar](20) NULL, [WMITable] [v