@@ -8,25 +8,31 @@ title: about_Logging
8
8
9
9
# About Logging
10
10
11
- ## Short Description
11
+ ## Short description
12
12
13
13
PowerShell logs internal operations from the engine, providers, and cmdlets.
14
14
15
- ## Long Description
15
+ ## Long description
16
16
17
- PowerShell logs details of PowerShell operations, such as starting and
18
- stopping the engine and starting and stopping providers. It will also log
19
- details about PowerShell commands.
17
+ PowerShell logs details about PowerShell operations, such as starting and
18
+ stopping the engine and providers, and executing PowerShell commands.
19
+
20
+ > [ !NOTE]
21
+ > Windows PowerShell versions 3.0, 4.0, 5.0, and 5.1 include ** EventLog**
22
+ > cmdlets for the Windows event logs. In those versions, to display the list of
23
+ > ** EventLog** cmdlets type: ` Get-Command -Noun EventLog ` . For more
24
+ > information, see the cmdlet documentation and about_EventLogs for your
25
+ > version of Windows PowerShell.
20
26
21
27
## Viewing the PowerShell event log entries on Windows
22
28
23
- PowerShell logs can be viewed using the Event Viewer. The event log is located
24
- in the Application and Services Logs group and is named
29
+ PowerShell logs can be viewed using the Windows Event Viewer. The event log is
30
+ located in the Application and Services Logs group and is named
25
31
` Microsoft-Windows-PowerShell ` . The associated ETW provider ` GUID ` is
26
32
` {A0C1853B-5C40-4B15-8766-3CF1C58F985A} ` .
27
33
28
- When script block logging is enabled, PowerShell will log the following events
29
- to the ` Microsoft-Windows-PowerShell/Operational ` log:
34
+ When Script Block Logging is enabled, PowerShell logs the following events to
35
+ the ` Microsoft-Windows-PowerShell/Operational ` log:
30
36
31
37
| Field| Value|
32
38
| -| -|
@@ -39,18 +45,21 @@ to the `Microsoft-Windows-PowerShell/Operational` log:
39
45
40
46
## Enabling Script Block Logging
41
47
42
- Any new PowerShell session will pick up the new setting after making one of the
43
- following changes.
48
+ When you enable Script Block Logging, PowerShell records the content of all
49
+ script blocks that it processes. Once enabled, any new PowerShell session logs
50
+ this information.
44
51
45
52
> [ !NOTE]
46
- > It is recommended to enable Protected Event Logging (as described below) when
47
- > using Script Block logging for anything other than diagnostics purposes.
53
+ > It's recommended to enable Protected Event Logging, as described below, when
54
+ > using Script Block Logging for anything other than diagnostics purposes.
55
+
56
+ Script Block Logging can be enabled via Group Policy or a registry setting.
48
57
49
58
### Using Group Policy
50
59
51
- To enable automatic transcription, enable the ' Turn on PowerShell Script Block
52
- Logging' feature in Group Policy through `Administrative Templates ->
53
- Windows Components -> Windows PowerShell`.
60
+ To enable automatic transcription, enable the ` Turn on PowerShell Script Block
61
+ Logging` feature in Group Policy through ` Administrative Templates -> Windows
62
+ Components -> Windows PowerShell`.
54
63
55
64
### Using the Registry
56
65
@@ -73,70 +82,67 @@ function Enable-PSScriptBlockLogging
73
82
74
83
## Protected Event Logging
75
84
76
- One concern when increasing the amount of logging on a system is the danger
77
- that logged content may contain sensitive data. For example, if you log the
78
- content of every PowerShell script that was run, there is the possibility that
79
- a script may contain credentials or other sensitive data.
85
+ Increasing the level of logging on a system increases the possibility that
86
+ logged content may contain sensitive data. For example, with script logging
87
+ enabled, credentials or other sensitive data used by a script can be written to
88
+ the event log. When a machine that has logged sensitive data is compromised,
89
+ the logs can provide an attacker with information needed to extend their reach.
80
90
81
- If an attacker later compromises a machine that has logged this data, it may
82
- provide them with additional information with which to extend their reach.
83
-
84
- To prevent this dilemma, Windows 10 introduces Protected Event Logging.
91
+ To protect this information, Windows 10 introduces Protected Event Logging.
85
92
Protected Event Logging lets participating applications encrypt sensitive data
86
- as they write it to the event log. You can then decrypt and process these logs
87
- once you've moved them to a more secure and centralized log collector.
88
-
89
- Protected Event Logging protects event log content through the IETF
90
- Cryptographic Message Syntax (CMS) standard. The CMS encryption standard
91
- implements public key cryptography, where the keys used to encrypt content
92
- (the public key) and the keys used to decrypt content (the private key) are
93
- separate.
94
-
95
- Your public key can be shared widely, and is not sensitive data. If any
96
- content is encrypted with this public key, only your private key can decrypt
97
- it. For more information about Public Key Cryptography, see
93
+ written to the event log. Later, you can decrypt and process these logs on a
94
+ more secure and centralized log collector.
95
+
96
+ Event log content is protected using the IETF Cryptographic Message Syntax
97
+ (CMS) standard. CMS uses public key cryptography. The keys used to encrypt
98
+ content and decrypt content are kept separate.
99
+
100
+ The public key can be shared widely and isn't sensitive data. Any content
101
+ encrypted with this public key can only be decrypted by the private key. For
102
+ more information about Public Key Cryptography, see
98
103
[ Wikipedia - Public Key Cryptography] ( https://en.wikipedia.org/wiki/Public-key_cryptography ) .
99
104
100
- When you implement a protected event logging policy, you deploy a public key
101
- to all machines that have event log data you want to protect. You retain the
102
- corresponding private key to post-process the event logs at a more secure
103
- location such as a central event log collector,
104
- or [ SIEM ] ( https://en.wikipedia.org/wiki/Security_information_and_event_management ) aggregator.
105
+ To enable a Protected Event Logging policy, deploy a public key to all machines
106
+ that have event log data to protect. The corresponding private key is used to
107
+ post-process the event logs at a more secure location such as a central event
108
+ log collector, or [ SIEM ] ( https://en.wikipedia.org/wiki/Security_information_and_event_management )
109
+ aggregator.
105
110
106
111
### Enabling Protected Event Logging via Group Policy
107
112
108
113
To enable Protected Event Logging, enable the ` Enable Protected Event Logging `
109
- feature in Group Policy through `Administrative Templates ->
110
- Windows Components -> Event Logging`. This setting requires an encryption certificate,
111
- which you can provide in one of several forms:
114
+ feature in Group Policy through `Administrative Templates -> Windows Components
115
+ -> Event Logging`. This setting requires an encryption certificate, which you
116
+ can provide in one of several forms:
112
117
113
118
- The content of a base-64 encoded X.509 certificate (for example, as offered
114
- by the ` Export ` option in Certificate Manager)
119
+ by the ` Export ` option in Certificate Manager).
115
120
- The thumbprint of a certificate that can be found in the Local Machine
116
- certificate store (can be deployed by PKI infrastructure)
117
- - The full path to a certificate (can be local, or a remote share)
121
+ certificate store (can be deployed by PKI infrastructure).
122
+ - The full path to a certificate (can be local, or a remote share).
118
123
- The path to a directory containing a certificate or certificates (can be
119
- local, or a remote share)
124
+ local, or a remote share).
120
125
- The subject name of a certificate that can be found in the Local Machine
121
- certificate store (can be deployed by PKI infrastructure)
126
+ certificate store (can be deployed by PKI infrastructure).
122
127
123
128
The resulting certificate must have ` Document Encryption ` as an enhanced key
124
- usage (` 1.3.6.1.4.1.311.80.1 ` ), as well as either ` Data Encipherment ` or `Key
129
+ usage (` 1.3.6.1.4.1.311.80.1 ` ), and either ` Data Encipherment ` or `Key
125
130
Encipherment` key usages enabled.
126
131
127
132
> [ !WARNING]
128
- > The private key should not be deployed to machines logging.
129
- > It should be kept in a secure location where you decrypt the messages.
133
+ > The private key shouldn't be deployed to the machines logging events. It
134
+ > should be kept in a secure location where you decrypt the messages.
130
135
131
- ### Decrypting Protected Event Log Messages
136
+ ### Decrypting Protected Event Logging messages
132
137
133
- The following script will retrieve and decrypt (assuming you have the private key):
138
+ The following script will retrieve and decrypt, assuming that you have the
139
+ private key:
134
140
135
141
``` powershell
136
142
Get-WinEvent Microsoft-Windows-PowerShell/Operational |
137
143
Where-Object Id -eq 4104 | Unprotect-CmsMessage
138
144
```
139
145
140
- ## See Also
146
+ ## See also
141
147
142
- [ PowerShell the Blue Team] ( https://blogs.msdn. microsoft.com/powershell/2015/06/09 /powershell-the-blue-team/ )
148
+ [ PowerShell the Blue Team] ( https://devblogs. microsoft.com/powershell/powershell-the-blue-team/ )
0 commit comments