Skip to content

Commit e976b2b

Browse files
committed
Replace sqlmgmproviderxpsp2up.mof for 2022+
1 parent 990afaa commit e976b2b

2 files changed

Lines changed: 197 additions & 192 deletions

File tree

Lines changed: 99 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,99 @@
1-
---
2-
description: "SqlErrorLogEvent Class"
3-
title: "SqlErrorLogEvent Class"
4-
ms.custom: ""
5-
ms.date: "03/14/2017"
6-
ms.service: sql
7-
ms.reviewer: ""
8-
ms.subservice: wmi
9-
ms.topic: "reference"
10-
helpviewer_keywords:
11-
- "SqlErrorLogEvent class"
12-
- "SqlErrorLogFile class"
13-
ms.assetid: bde6c467-38d0-4766-a7af-d6c9d6302b07
14-
author: markingmyname
15-
ms.author: maghan
16-
---
17-
# SqlErrorLogEvent Class
18-
[!INCLUDE[sqlserver](../../includes/applies-to-version/sqlserver.md)]
19-
Provides properties for viewing events in a specified [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file.
20-
21-
## Syntax
22-
23-
```
24-
25-
class SQLErrorLogEvent
26-
{
27-
stringFileName;
28-
stringInstanceName;
29-
datetimeLogDate;
30-
stringMessage;
31-
stringProcessInfo;
32-
};
33-
```
34-
35-
## Properties
36-
The SQLErrorLogEvent class defines the following properties.
37-
38-
| Property | Description |
39-
| -------- | ----------- |
40-
|FileName|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> The name of the error log file.|
41-
|InstanceName|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> Qualifiers: Key<br /><br /> The name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] where the log file resides.|
42-
|LogDate|Data type: **datetime**<br /><br /> Access type: Read-only<br /><br /> Qualifiers: Key<br /><br /> <br /><br /> The date and time that the event was recorded in the log file.|
43-
|Message|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> The event message.|
44-
|ProcessInfo|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> Information about the source server process ID (SPID) for the event.|
45-
46-
## Remarks
47-
48-
| Type | Name |
49-
| ---- | ---- |
50-
|MOF|Sqlmgmproviderxpsp2up.mof|
51-
|DLL|Sqlmgmprovider.dll|
52-
|Namespace|\root\Microsoft\SqlServer\ComputerManagement10|
53-
54-
## Example
55-
The following example shows how to retrieve values for all logged events in a specified log file. To run the example, replace \<*Instance_Name*> with the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], such as 'Instance1', and replace 'File_Name' with the name of the error log file, such as 'ERRORLOG.1'.
56-
57-
```
58-
on error resume next
59-
strComputer = "."
60-
Set objWMIService = GetObject("winmgmts:" _
61-
& "{impersonationLevel=impersonate}!\\" _
62-
& strComputer & "\root\MICROSOFT\SqlServer\ComputerManagement10")
63-
set logEvents = objWmiService.ExecQuery("SELECT * FROM SqlErrorLogEvent WHERE InstanceName = '<Instance_Name>' AND FileName = 'File_Name'")
64-
65-
For Each logEvent in logEvents
66-
WScript.Echo "Instance Name: " & logEvent.InstanceName & vbNewLine _
67-
& "Log Date: " & logEvent.LogDate & vbNewLine _
68-
& "Log File Name: " & logEvent.FileName & vbNewLine _
69-
& "Process Info: " & logEvent.ProcessInfo & vbNewLine _
70-
& "Message: " & logEvent.Message & vbNewLine _
71-
72-
Next
73-
```
74-
75-
## Comments
76-
When *InstanceName* or *FileName* are not provided in the WQL statement, the query will return information for the default instance and the current [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file. For example, the following WQL statement will return all log events from the current log file (ERRORLOG) on the default instance (MSSQLSERVER).
77-
78-
```
79-
"SELECT * FROM SqlErrorLogEvent"
80-
```
81-
82-
## Security
83-
To connect to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file through WMI, you must have the following permissions on both the local and remote computers:
84-
85-
- Read access to the **Root\Microsoft\SqlServer\ComputerManagement10** WMI namespace. By default, everyone has read access through the Enable Account permission.
86-
87-
- Read permission to the folder that contains the error logs. By default the error logs are located in the following path (where \<*Drive>* represents the drive where you installed [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and \<*InstanceName*> is the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]):
88-
89-
**\<Drive>:\Program Files\Microsoft SQL Server\MSSQL13** **.\<InstanceName>\MSSQL\Log**
90-
91-
If you are connecting through a firewall, ensure that an exception is set in the firewall for WMI on remote target computers. For more information, see [Connecting to WMI Remotely Starting with Windows Vista](/windows/win32/wmisdk/connecting-to-wmi-remotely-starting-with-vista).
92-
93-
## See Also
94-
[SqlErrorLogFile Class](../../relational-databases/wmi-provider-configuration-classes/sqlerrorlogfile-class.md)
95-
[View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md)
96-
1+
---
2+
title: SqlErrorLogEvent class
3+
description: Provides properties for viewing events in a specified SQL Server log file.
4+
author: markingmyname
5+
ms.author: maghan
6+
ms.reviewer: randolphwest
7+
ms.date: 02/23/2023
8+
ms.service: sql
9+
ms.subservice: wmi
10+
ms.topic: "reference"
11+
helpviewer_keywords:
12+
- "SqlErrorLogEvent class"
13+
- "SqlErrorLogFile class"
14+
---
15+
# SqlErrorLogEvent class
16+
17+
[!INCLUDE[sqlserver](../../includes/applies-to-version/sqlserver.md)]
18+
19+
Provides properties for viewing events in a specified [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file.
20+
21+
## Syntax
22+
23+
```csharp
24+
class SQLErrorLogEvent
25+
{
26+
stringFileName;
27+
stringInstanceName;
28+
datetimeLogDate;
29+
stringMessage;
30+
stringProcessInfo;
31+
};
32+
```
33+
34+
## Properties
35+
36+
The SQLErrorLogEvent class defines the following properties.
37+
38+
| Property | Description |
39+
| --- | --- |
40+
| FileName | Data type: **string**<br /><br />Access type: Read-only<br /><br />The name of the error log file. |
41+
| InstanceName | Data type: **string**<br /><br />Access type: Read-only<br /><br />Qualifiers: Key<br /><br />The name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] where the log file resides. |
42+
| LogDate | Data type: **datetime**<br /><br />Access type: Read-only<br /><br />Qualifiers: Key<br /><br />The date and time that the event was recorded in the log file. |
43+
| Message | Data type: **string**<br /><br />Access type: Read-only<br /><br />The event message. |
44+
| ProcessInfo | Data type: **string**<br /><br />Access type: Read-only<br /><br />Information about the source server process ID (SPID) for the event. |
45+
46+
## Remarks
47+
48+
| Type | Name |
49+
| --- | --- |
50+
| MOF | - `sqlmgmprovider.mof` ([!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions)<br />- `sqlmgmproviderxpsp2up.mof` ([!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] and earlier versions) |
51+
| DLL | `sqlmgmprovider.dll` |
52+
| Namespace | `\root\Microsoft\SqlServer\ComputerManagement10` |
53+
54+
## Example
55+
56+
The following example shows how to retrieve values for all logged events in a specified log file. To run the example, replace \<*Instance_Name*> with the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], such as 'Instance1', and replace 'File_Name' with the name of the error log file, such as 'ERRORLOG.1'.
57+
58+
```vbnet
59+
on error resume next
60+
strComputer = "."
61+
Set objWMIService = GetObject("winmgmts:" _
62+
& "{impersonationLevel=impersonate}!\\" _
63+
& strComputer & "\root\MICROSOFT\SqlServer\ComputerManagement10")
64+
set logEvents = objWmiService.ExecQuery("SELECT * FROM SqlErrorLogEvent WHERE InstanceName = '<Instance_Name>' AND FileName = 'File_Name'")
65+
66+
For Each logEvent in logEvents
67+
WScript.Echo "Instance Name: " & logEvent.InstanceName & vbNewLine _
68+
& "Log Date: " & logEvent.LogDate & vbNewLine _
69+
& "Log File Name: " & logEvent.FileName & vbNewLine _
70+
& "Process Info: " & logEvent.ProcessInfo & vbNewLine _
71+
& "Message: " & logEvent.Message & vbNewLine _
72+
73+
Next
74+
```
75+
76+
## Comments
77+
78+
When *InstanceName* or *FileName* aren't provided in the WQL statement, the query returns information for the default instance and the current [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file. For example, the following WQL statement returns all log events from the current log file (ERRORLOG) on the default instance (MSSQLSERVER).
79+
80+
```wql
81+
"SELECT * FROM SqlErrorLogEvent"
82+
```
83+
84+
## Security
85+
86+
To connect to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file through WMI, you must have the following permissions on both the local and remote computers:
87+
88+
- Read access to the **Root\Microsoft\SqlServer\ComputerManagement10** WMI namespace. By default, everyone has read access through the Enable Account permission.
89+
90+
- Read permission to the folder that contains the error logs. By default the error logs are located in the following path (where \<*Drive>* represents the drive where you installed [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and \<*InstanceName*> is the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]):
91+
92+
**\<Drive>:\Program Files\Microsoft SQL Server\MSSQL13** **.\<InstanceName>\MSSQL\Log**
93+
94+
If you're connecting through a firewall, ensure that an exception is set in the firewall for WMI on remote target computers. For more information, see [Connecting to WMI Remotely Starting with Windows Vista](/windows/win32/wmisdk/connecting-to-wmi-remotely-starting-with-vista).
95+
96+
## See also
97+
98+
- [SqlErrorLogFile Class](../../relational-databases/wmi-provider-configuration-classes/sqlerrorlogfile-class.md)
99+
- [View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md)
Lines changed: 98 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,98 @@
1-
---
2-
description: "SqlErrorLogFile Class"
3-
title: "SqlErrorLogFile Class"
4-
ms.custom: ""
5-
ms.date: "03/14/2017"
6-
ms.service: sql
7-
ms.reviewer: ""
8-
ms.subservice: wmi
9-
ms.topic: "reference"
10-
ms.assetid: 2b83ae4a-c0d4-414c-b6e5-a41ec7c13159
11-
author: markingmyname
12-
ms.author: maghan
13-
---
14-
# SqlErrorLogFile Class
15-
[!INCLUDE[sqlserver](../../includes/applies-to-version/sqlserver.md)]
16-
Provides properties for viewing information about a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file.
17-
18-
## Syntax
19-
20-
```
21-
22-
class SQLErrorLogFile
23-
{
24-
uint32ArchiveNumber;
25-
stringInstanceName;
26-
datetimeLastModified;
27-
uint32LogFileSize;
28-
stringName;
29-
30-
};
31-
```
32-
33-
## Properties
34-
The SQLErrorLogFile class defines the following properties.
35-
36-
| Property | Description |
37-
| -------- | ----------- |
38-
|ArchiveNumber|Data type: **uint32**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> The archive number for the log file.|
39-
|InstanceName|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> Qualifiers: Key<br /><br /> <br /><br /> The name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] where the log file resides.|
40-
|LastModified|Data type: **datetime**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> The date that the log file was last modified.|
41-
|LogFileSize|Data type: **uint32**<br /><br /> Access type: Read-only<br /><br /> <br /><br /> The log file size, in bytes.|
42-
|Name|Data type: **string**<br /><br /> Access type: Read-only<br /><br /> Qualifiers: Key<br /><br /> <br /><br /> The name of the log file.|
43-
44-
## Remarks
45-
46-
| Type | Name |
47-
| ---- | ---- |
48-
|MOF|Sqlmgmprovider xpsp2up.mof|
49-
|DLL|Sqlmgmprovider.dll|
50-
|Namespace|\root\Microsoft\SqlServer\ComputerManagement10|
51-
52-
## Example
53-
The following example retrieves information about all [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log files on a specified instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. To run the example, replace \<*Instance_Name*> with the name of the instance, for example, 'Instance1'.
54-
55-
```
56-
on error resume next
57-
set strComputer = "."
58-
set objWMIService = GetObject("winmgmts:\\.\root\Microsoft\SqlServer\ComputerManagement10")
59-
set LogFiles = objWmiService.ExecQuery("SELECT * FROM SqlErrorLogFile WHERE InstanceName = '<Instance_Name>'")
60-
61-
For Each logFile in LogFiles
62-
63-
WScript.Echo "Instance Name: " & logFile.InstanceName & vbNewLine _
64-
& "Log File Name: " & logFile.Name & vbNewLine _
65-
& "Archive Number: " & logFile.ArchiveNumber & vbNewLine _
66-
& "Log File Size: " & logFile.LogFileSize & " bytes" & vbNewLine _
67-
& "Last Modified: " & logFile.LastModified & vbNewLine _
68-
69-
Next
70-
```
71-
72-
## Comments
73-
When *InstanceName* is not provided in the WQL statement, the query will return information for the default instance. For example, the following WQL statement will return information about all log files from the default instance (MSSQLSERVER).
74-
75-
```
76-
"SELECT * FROM SqlErrorLogFile"
77-
```
78-
79-
## Security
80-
To connect to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file through WMI, you must have the following permissions on both the local and remote computers:
81-
82-
- Read access to the **Root\Microsoft\SqlServer\ComputerManagement10** WMI namespace. By default, everyone has read access through the Enable Account permission.
83-
84-
> [!NOTE]
85-
> For information about how to verify WMI permissions, see the Security section of the topic [View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md).
86-
87-
- Read permission to the folder that contains the error logs. By default the error logs are located in the following path (where \<*Drive>* represents the drive where you installed [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and \<*InstanceName*> is the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]):
88-
89-
**\<Drive>:\Program Files\Microsoft SQL Server\MSSQL11** **.\<InstanceName>\MSSQL\Log**
90-
91-
If you are connecting through a firewall, ensure that an exception is set in the firewall for WMI on remote target computers. For more information, see [Connecting to WMI Remotely Starting with Windows Vista](/windows/win32/wmisdk/connecting-to-wmi-remotely-starting-with-vista).
92-
93-
## See Also
94-
[SqlErrorLogEvent Class](../../relational-databases/wmi-provider-configuration-classes/sqlerrorlogevent-class.md)
95-
[View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md)
96-
1+
---
2+
title: SqlErrorLogFile class
3+
description: Provides properties for viewing information about a SQL Server log file.
4+
author: markingmyname
5+
ms.author: maghan
6+
ms.reviewer: randolphwest
7+
ms.date: 02/23/2023
8+
ms.service: sql
9+
ms.subservice: wmi
10+
ms.topic: "reference"
11+
---
12+
# SqlErrorLogFile class
13+
14+
[!INCLUDE[sqlserver](../../includes/applies-to-version/sqlserver.md)]
15+
16+
Provides properties for viewing information about a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file.
17+
18+
## Syntax
19+
20+
```csharp
21+
class SQLErrorLogFile
22+
{
23+
uint32ArchiveNumber;
24+
stringInstanceName;
25+
datetimeLastModified;
26+
uint32LogFileSize;
27+
stringName;
28+
};
29+
```
30+
31+
## Properties
32+
33+
The SQLErrorLogFile class defines the following properties.
34+
35+
| Property | Description |
36+
| --- | --- |
37+
| ArchiveNumber | Data type: **uint32**<br /><br />Access type: Read-only<br /><br />The archive number for the log file. |
38+
| InstanceName | Data type: **string**<br /><br />Access type: Read-only<br /><br />Qualifiers: Key<br /><br />The name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] where the log file resides. |
39+
| LastModified | Data type: **datetime**<br /><br />Access type: Read-only<br /><br />The date that the log file was last modified. |
40+
| LogFileSize | Data type: **uint32**<br /><br />Access type: Read-only<br /><br />The log file size, in bytes. |
41+
| Name | Data type: **string**<br /><br />Access type: Read-only<br /><br />Qualifiers: Key<br /><br />The name of the log file. |
42+
43+
## Remarks
44+
45+
| Type | Name |
46+
| --- | --- |
47+
| MOF | - `sqlmgmprovider.mof` ([!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions)<br />- `sqlmgmproviderxpsp2up.mof` ([!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] and earlier versions) |
48+
| DLL | `sqlmgmprovider.dll` |
49+
| Namespace | `\root\Microsoft\SqlServer\ComputerManagement10` |
50+
51+
## Example
52+
53+
The following example retrieves information about all [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log files on a specified instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. To run the example, replace \<*Instance_Name*> with the name of the instance, for example, 'Instance1'.
54+
55+
```vbnet
56+
on error resume next
57+
set strComputer = "."
58+
set objWMIService = GetObject("winmgmts:\\.\root\Microsoft\SqlServer\ComputerManagement10")
59+
set LogFiles = objWmiService.ExecQuery("SELECT * FROM SqlErrorLogFile WHERE InstanceName = '<Instance_Name>'")
60+
61+
For Each logFile in LogFiles
62+
63+
WScript.Echo "Instance Name: " & logFile.InstanceName & vbNewLine _
64+
& "Log File Name: " & logFile.Name & vbNewLine _
65+
& "Archive Number: " & logFile.ArchiveNumber & vbNewLine _
66+
& "Log File Size: " & logFile.LogFileSize & " bytes" & vbNewLine _
67+
& "Last Modified: " & logFile.LastModified & vbNewLine _
68+
69+
Next
70+
```
71+
72+
## Comments
73+
74+
When *InstanceName* isn't provided in the WQL statement, the query returns information for the default instance. For example, the following WQL statement returns information about all log files from the default instance (MSSQLSERVER).
75+
76+
```wql
77+
"SELECT * FROM SqlErrorLogFile"
78+
```
79+
80+
## Security
81+
82+
To connect to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] log file through WMI, you must have the following permissions on both the local and remote computers:
83+
84+
- Read access to the **Root\Microsoft\SqlServer\ComputerManagement10** WMI namespace. By default, everyone has read access through the Enable Account permission.
85+
86+
> [!NOTE]
87+
> For information about how to verify WMI permissions, see the Security section of the topic [View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md).
88+
89+
- Read permission to the folder that contains the error logs. By default the error logs are located in the following path (where \<*Drive>* represents the drive where you installed [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and \<*InstanceName*> is the name of the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]):
90+
91+
**\<Drive>:\Program Files\Microsoft SQL Server\MSSQL11** **.\<InstanceName>\MSSQL\Log**
92+
93+
If you're connecting through a firewall, ensure that an exception is set in the firewall for WMI on remote target computers. For more information, see [Connecting to WMI Remotely Starting with Windows Vista](/windows/win32/wmisdk/connecting-to-wmi-remotely-starting-with-vista).
94+
95+
## See also
96+
97+
- [SqlErrorLogEvent Class](../../relational-databases/wmi-provider-configuration-classes/sqlerrorlogevent-class.md)
98+
- [View Offline Log Files](../../relational-databases/logs/view-offline-log-files.md)

0 commit comments

Comments
 (0)