vSphere PowerCLI Reference



Retrieves entries from vSphere logs.


Get-Log [-Key] <String[]> [[-VMHost] <VMHost[]>] [[-StartLineNum] <Int32>] [[-NumLines] <Int32>] [-Server <VIServer[]>] [<CommonParameters>]
Get-Log [[-VMHost] <VMHost[]>] [-Bundle] [-DestinationPath] <String> [-Server <VIServer[]>] [-RunAsync] [<CommonParameters>]

Related Commands

Online version

Detailed Description

Retrieves entries from vSphere logs. Returns portions of the log files according to the criteria provided by the cmdlet parameters.
To specify a server different from the default one, use the -Server parameter.


NameTypeDescriptionRequired?Pipeline InputDefault Value
KeyString[]Specify the key identifier of the log file you want to retrieve. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.truetrue (ByValue)
VMHostVMHost[]Specify the hosts for which you want to retrieve logs. If no value is given to this parameter, the command returns logs only for the default vSphere server.falsetrue (ByValue)
DestinationPathStringSpecify a local file path where you want to save the log bundle.truefalse
StartLineNumInt32Specify the start line number for reading from the logs.falsefalse
NumLinesInt32Specify the number of the lines you want to retrieve from the logs.falsefalse
BundleSwitchParameterIndicate whether to retrieve a diagnostic bundle of logs from the vSphere server.falsefalse
RunAsyncSwitchParameterIndicate that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the -RunAsync parameter run " help About_RunAsync" in the vSphere PowerCLI console.falsefalse
ServerVIServer[]A vSphere servers to apply the command on. If no value is given to this parameter, the command runs on the server currently specified in the $DefaultVIServer variable.falsefalse

Return Type

Log or LogBundle



-------------- Example 1 --------------

$keys = Get-LogType   Get-Log -Key $keys[0]

Obtain the available keys. Obtains the first log file from the currently connected vSphere server.

-------------- Example 2 --------------

$host = Get-VMHost Host  $keyList = Get-LogType -VMHost $host  $host | Get-Log -Key $keyList[0] -StartLineNum 1 -NumLines 100

Retrieve the first one hundred log lines for the specified host and key.

-------------- Example 3 --------------

Get-VMost Host | Get-Log -Bundle -DestinationPath "D:\VMHostBundeLog"

Retrieve a bundle log for the specified host.

Copyright © 1998 - 2011 VMware, Inc. All rights reserved.