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

Get-AzNetworkWatcherPacketCapture

Gets information and properties and status of a packet capture resource.

Syntax

Get-AzNetworkWatcherPacketCapture
   -NetworkWatcher <PSNetworkWatcher>
   [-PacketCaptureName <String>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzNetworkWatcherPacketCapture
   -NetworkWatcherName <String>
   -ResourceGroupName <String>
   [-PacketCaptureName <String>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzNetworkWatcherPacketCapture
   -Location <String>
   [-PacketCaptureName <String>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Get-AzNetworkWatcherPacketCapture gets the properties and status of a packet capture resource.

Examples

Example 1: Create a Packet Capture with multiple filters and retrieve its status

$nw = Get-AzResource | Where-Object {$_.ResourceType -eq "Microsoft.Network/networkWatchers" -and $_.Location -eq "WestCentralUS" } 
$networkWatcher = Get-AzNetworkWatcher -Name $nw.Name -ResourceGroupName $nw.ResourceGroupName 

$storageAccount = Get-AzStorageAccount -ResourceGroupName contosoResourceGroup -Name contosostorage123

$filter1 = New-AzPacketCaptureFilterConfig -Protocol TCP -RemoteIPAddress "1.1.1.1-255.255.255" -LocalIPAddress "10.0.0.3" -LocalPort "1-65535" -RemotePort "20;80;443"
$filter2 = New-AzPacketCaptureFilterConfig -Protocol UDP 
New-AzNetworkWatcherPacketCapture -NetworkWatcher $networkWatcher -TargetVirtualMachineId $vm.Id -PacketCaptureName "PacketCaptureTest" -StorageAccountId $storageAccount.id -TimeLimitInSeconds 60 -Filter $filter1, $filter2

Get-AzNetworkWatcherPacketCapture -NetworkWatcher $networkWatcher -PacketCaptureName "PacketCaptureTest"

In this example we create a packet capture named "PacketCaptureTest" with multiple filters and a time limit. Once the session is complete, it will be saved to the specified storage account. We then call Get-AzNetworkWatcherPacketCapture to retrieve the status of the capture session. Note: The Azure Network Watcher extension must be installed on the target virtual machine to create packet captures.

Note

If you create a reference to the packet capture directly from the New-AzNetworkWatcherPacketCapture command, it won't have all the properties. You can get all of the properties of the packet capture by making a call to the Get-AzNetworkWatcherPacketCapture command.

Example 2: Create a Packet Capture with multiple filters and retrieve its status

Get-AzNetworkWatcherPacketCapture -ResourceGroupName rg1 -NetworkWatcherName nw1 -PacketCaptureName PacketCapture*

This cmdlet returns all PacketCaptures that start with "PacketCapture" in the nw1 Network Watcher.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Location

Location of the network watcher.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-NetworkWatcher

The network watcher resource.

Type:PSNetworkWatcher
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NetworkWatcherName

The name of network watcher.

Type:String
Aliases:Name
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PacketCaptureName

The packet capture name.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-ResourceGroupName

The name of the network watcher resource group.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

PSNetworkWatcher

String

Outputs

PSGetPacketCaptureResult

Notes

Keywords: azure, azurerm, arm, resource, management, manager, network, networking, network watcher, packet, capture, traffic