< Back

Get-Log

Sun Jan 19, 2020 6:50 pm

NAME Get-Log



SYNOPSIS

This cmdlet retrieves entries from vSphere logs.





SYNTAX

Get-Log [-DestinationPath] <String> [[-VMHost] <VMHost[]>] [-Bundle] [-RunAsync] [-Server <VIServer[]>]

[<CommonParameters>]



Get-Log [-Key] <String[]> [[-VMHost] <VMHost[]>] [[-StartLineNum] <Int32>] [[-NumLines] <Int32>] [-Server

<VIServer[]>] [<CommonParameters>]





DESCRIPTION

This cmdlet 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.





PARAMETERS

-Bundle [<SwitchParameter>]

Indicates whether to retrieve a diagnostic bundle of logs from vCenter Server.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-DestinationPath <String>

Specifies a local file path where you want to save the log bundle.



Required? true

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Key <String[]>

Specifies 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.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-NumLines <Int32>

Specifies the number of the lines you want to retrieve from the logs.



Required? false

Position? 4

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-RunAsync [<SwitchParameter>]

Indicates 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 VMware PowerCLI console.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this

parameter, the command runs on the default servers. For more information about default servers, see the

description of Connect-VIServer.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-StartLineNum <Int32>

Specifies the start line number for reading from the logs.



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VMHost <VMHost[]>

Specifies 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 vCenter Server system.



Required? false

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more Log or LogBundle objects







NOTES









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



$keys = Get-LogType



Get-Log -Key $keys[0]



Obtain the available keys. Obtains the first log file from the currently connected vCenter Server system.

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



$vmhost = Get-VMHost Host



$keyList = Get-LogType -VMHost $vmhost



$vmhost | 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-VMHost Host | Get-Log -Bundle -DestinationPath "D:\\VMHostBundeLog"



Retrieve a bundle log for the specified host.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... t-Log.html

Get-LogType