你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Get-AzLog

Retrieve Activity Log events.

语法

GetByCorrelationId

Get-AzLog
    [-CorrelationId] <String>
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Status <String>]
    [-Caller <String>]
    [-DetailedOutput]
    [-MaxRecord <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetByResourceId

Get-AzLog
    [-ResourceId] <String>
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Status <String>]
    [-Caller <String>]
    [-DetailedOutput]
    [-MaxRecord <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetByResourceGroup

Get-AzLog
    [-ResourceGroupName] <String>
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Status <String>]
    [-Caller <String>]
    [-DetailedOutput]
    [-MaxRecord <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetByResourceProvider

Get-AzLog
    [-ResourceProvider] <String>
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Status <String>]
    [-Caller <String>]
    [-DetailedOutput]
    [-MaxRecord <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetBySubscription

Get-AzLog
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Status <String>]
    [-Caller <String>]
    [-DetailedOutput]
    [-MaxRecord <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

说明

The Get-AzLog cmdlet retrieve Activity Log events. The events can be associated with the current subscription ID, correlation ID, resource group, resource ID, or resource provider.

示例

Example 1: Get an event log by subscription ID

PS C:\>Get-AzLog

This command lists at most 1000 events associated with the user's subscription ID that took place 7 days from the current date/time.

Example 2: Get an event log by subscription ID with a maximum number of events

PS C:\>Get-AzLog -MaxRecord 100

This command lists at most 100 events associated with the user's subscription ID that took place 7 days from the current date/time.

Example 3: Get an event log by subscription ID with a start time.

PS C:\>Get-AzLog -StartTime 2017-06-01T10:30

This command lists at most 1000 events associated with the user's subscription ID that took place on or after 2017-06-01T10:30 local time if that date/time is not older than 90 days from the current date/time.

Example 4: Get an event log by subscription ID with a start time and end time.

PS C:\>Get-AzLog -StartTime 2017-04-01T10:30 -EndTime 2017-04-14T11:30

This command lists at most 1000 of the events associated with the user's subscription ID that took place on or after 2017-04-01T10:30 local time, and before 2017-04-14T11:30 local time if the whole date/time range is not older than 90 days from the current date/time, i.e.: the retention period.

Example 5: Get an event log by correlation ID

PS C:\>Get-AzLog -CorrelationId "aaaa0000-bb11-2222-33cc-444444dddddd"

This command lists at most 1000 events associated with the specified correlation ID that took place 7 days from the current date/time. NOTE: this is usually only one event.

Example 6: Get an event log by correlation ID with a maximum number of events

PS C:\>Get-AzLog -CorrelationId "aaaa0000-bb11-2222-33cc-444444dddddd" -MaxRecord 100

This command lists at most 100 events associated with the specified correlation ID that took place 7 days from the current date/time. NOTE: this is usually only one event.

Example 7: Get an event log by correlation ID and start time

PS C:\>Get-AzLog -CorrelationId "aaaa0000-bb11-2222-33cc-444444dddddd" -StartTime 2017-05-22T04:30:00

This command lists at most 1000 events associated with the specified correlation ID that took place on or after 2017-05-22T04:30:00 local time if the start time is not older than 90 days from the current date/time. NOTE: this is usually only one event.

Example 8: Get an event log by correlation ID with start time and end time

PS C:\>Get-AzLog -CorrelationId "aaaa0000-bb11-2222-33cc-444444dddddd" -StartTime 2017-04-15T04:30:00 -EndTime 2017-04-25T12:30:00

This command lists at most 1000 events associated with the specified correlation ID that took place on or after 2017-04-15T04:30 local time, but before 2017-04-25T12:30 local time if the whole date/time range is not older than 90 days from the current date/time, i.e.: the retention period.

Example 9: Get an event log for a resource group

PS C:\>Get-AzLog -ResourceGroupName "Contoso-Web-CentralUS"

This command lists at most 1000 the events associated with the specified resource group that took place 7 days from the current date/time.

Example 10: Get an event log for a resource group with a maximum number of events

PS C:\>Get-AzLog -ResourceGroup "Contoso-Web-CentralUS" -MaxRecord 100

This command lists at most 100 events associated with the specified resource group that took place 7 days from the current date/time.

Example 11: Get an event log for a resource group by start time

PS C:\>Get-AzLog -ResourceGroup "Contoso-Web-CentralUS" -StartTime 2017-05-22T04:30:00

This command lists at most 1000 events associated with the specified resource group that took place on or after 2017-05-22T04:30:00 local time if the start time is not older than 90 days from the current date/time.

Example 12: Get an event log for a resource group with a start time and end time

PS C:\>Get-AzLog -ResourceGroup "Contoso-Web-CentralUS" -StartTime 2017-04-15T04:30 -EndTime 2017-04-25T12:30

This command lists at most 1000 events associated with the specified resource group that took place on or after 2017-04-15T04:30 local time, but before 2017-04-25T12:30 local time if the whole date/time range is not older than 90 days from the current date/time, i.e.: the retention period.

Example 13: Get an event log by resource ID

PS C:\>Get-AzLog -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/ResourceGroups/Contoso-Web-CentralUS/providers/Microsoft.Web/ServerFarms/Contoso1"

This command lists at most 1000 events associated with the specified resource ID that took place 7 days from the current date/time.

Example 14: Get an event log by resource ID with a maximum number of events

PS C:\>Get-AzLog -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/ResourceGroups/Contoso-Web-CentralUS/providers/Microsoft.Web/ServerFarms/Contoso1" -MaxRecord 100

This command lists at most 100 events associated with the specified resource ID that took place 7 days from the current date/time.

Example 15: Get an event log by resource ID with a start time

PS C:\>Get-AzLog -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/ResourceGroups/Contoso-Web-CentralUS/providers/Microsoft.Web/ServerFarms/Contoso1" -StartTime 2017-05-22T04:30

This command lists at most 1000 events associated with the specified resource ID that took place on or after 2017-05-22T04:30:00 local time if the start time is not older than 90 days from the current date/time.

Example 16: Get an event log by resource ID with a start time and end time

PS C:\>Get-AzLog -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/ResourceGroups/Contoso-Web-CentralUS/providers/Microsoft.Web/ServerFarms/Contoso1" -StartTime 2017-04-15T04:30 -EndTime 2017-04-25T12:30

This command lists at most 1000 events associated with the specified resource ID that took place on or after 2017-04-15T04:30 local time, but before 2017-04-25T12:30 local time if the whole date/time range is not older than 90 days from the current date/time, i.e.: the retention period.

Example 17: Get an event log by resource provider

PS C:\>Get-AzLog -ResourceProvider "Microsoft.Web"

This command lists at most 1000 events associated with the specified resource provider that took place 7 days from the current date/time.

Example 18: Get an event log by resource provider with a maximum number of events

PS C:\>Get-AzLog -ResourceProvider "Microsoft.Web" -MaxRecord 100

This command lists at most 100 events associated with the specified resource provider that took place 7 days from the current date/time.

Example 19: Get an event log by resource provider with a start time

PS C:\>Get-AzLog -ResourceProvider "Microsoft.Web" -StartTime 2017-05-22T04:30

This command lists at most 1000 events associated with the specified resource provider that took place on or after 2017-05-22T04:30:00 local time if the start time is not older than 90 days from the current date/time.

Example 20: Get an event log by resource provider with a start time and end time

PS C:\>Get-AzLog -ResourceProvider "Microsoft.Web" -StartTime 2017-04-15T04:30 -EndTime 2017-04-25T12:30

This command lists at most 1000 events associated with the specified resource provider that took place on or after 2017-04-15T04:30 local time, but before 2017-04-25T12:30 local time if the whole date/time range is not older than 90 days from the current date/time, i.e.: the retention period.

参数

-Caller

Specifies a caller.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-CorrelationId

Specifies the correlation ID. This parameter is required.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetByCorrelationId
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DetailedOutput

Indicates that this cmdlet displays detailed output. By default, output is summarized.

参数属性

类型:SwitchParameter
默认值:Switch not present = False, i.e. output summarized
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-EndTime

Specifies the end time of the query in local time. The default value is the current time. The value must be later than StartTime. You can use the Get-Date cmdlet to get a DateTime object.

参数属性

类型:

Nullable<T>[DateTime]

默认值:Current date (time: 00:00:00 AM) + 1 day
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-MaxRecord

Specifies the total number of records to fetch for the specified filter. The default value is 1000 and the maximum value accepted is 100000. Negative values and 0 are ignored and the default value will be used.

参数属性

类型:Int32
默认值:1000
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceGroupName

Specifies the name of the resource group.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:ResourceGroup

参数集

GetByResourceGroup
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceId

Specifies the resource ID.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetByResourceId
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceProvider

Specifies a filter by resource provider.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetByResourceProvider
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-StartTime

Specifies the start time of the query in local time. The default value is EndTime minus seven days. You can use the Get-Date cmdlet to get a DateTime object.

参数属性

类型:

Nullable<T>[DateTime]

默认值:EndTime - 7 days
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Status

Specifies the status.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

Nullable<T>

String

SwitchParameter

Int32

输出

PSEventData