Skip to content

Log Functions

Jeff Buenting edited this page Apr 17, 2019 · 20 revisions

Overview

Functions that deal with VMWare Logs.

Functions

Get-VMWareHostLogList
Get-VMWareHostLog
Get-VMWareVMLog
Test-VMWareHostConnection



Get-VMWareHostLogList


    .SYNOPSIS
        Retrieves a list of existing log files on an ESX host.

    .DESCRIPTION
        This function is used to obtain a list of log files located in the default location of a VMWare         ESX server (/var/log/)

    .PARAMETER SSHSession
        SSHSession object created with POSH SSH New-SSHSession

    .EXAMPLE
        List all logs on server $Server.

        $SSH = New-SSHSession -ComputerName $Server -Credential $RootCred -AcceptKey
            -KeepAliveInterval 5
        $LogNames = Get-VMWareHostLogList -SSHSession $SSH

    .Notes
        Requires POSH SSH

Back to Top



Get-VMWareHostLog


    .SYNOPSIS
        Retrieves the log file data from an ESX server.

    .DESCRIPTION
        This function is used to obtain the data entries in a VMWare ESX host server log file.

    .PARAMETER SSHSession
        SSHSession object created with POSH SSH New-SSHSession

    .PARAMETER LogName
        Name of the log to retrieve.

    .EXAMPLE
        Retrieve the FDM.Log data from $Server.

        $SSH = New-SSHSession -ComputerName $Server -Credential $RootCred -AcceptKey
            -KeepAliveInterval 5
        $Log = Get-VMWareHostLog -SSHSession $SSH -LogName FDM.Log

    .Notes
        Requires POSH SSH

Back to Top



Get-VMWareVMLog


    .SYNOPSIS
        Retrieve the virtual machine logs

    .DESCRIPTION
        The function retrieves the logs from one or more virtual machines and stores them in a         local folder

    .PARAMETER VM
        The virtual machine(s) for which you want to retrieve the logs.

    .PARAMETER Path
        The folderpath where the virtual machines logs will be stored. The function creates a folder with         the name of the virtual machine in the specified path.

    .EXAMPLE
        PS> Get-VMLog -VM $vm -Path "C:\VMLogs"

    .EXAMPLE
        PS> Get-VM | Get-VMLog -Path "C:\VMLogs"

    .LINKS
        http://www.lucd.info/2011/02/27/virtual-machine-logging/

Back to Top



Test-VMWareHostConnection


    .SYNOPSIS
        VMKping or ping via ESXCLI

    .DESCRIPTION
        I got tired of doing this manually so I created this function to build and do it for me. It will ping         using either ESXCLI or VMKPing via SSH.

    .PARAMETER VMHost
        IP of the host to ping from.

    .PARAMETER IPAddress
        IP of the destination that is being pinged.

    .PARAMETER SSH
        SSH Session object for the VMHost. Obtained with using New-SSHSession from Posh-SSH.

    .PARAMETER VMKernelPort
        VMKernel Interface the ping will be sent out.

    .PARAMETER Count         Number of pings.

    .EXAMPLE
        Ping by SSH into Host.

    $RootCred = get-credential
    $SSH = New-SSHSession -ComputerName $Server -Credential $RootCred -AcceptKey -KeepAliveInterval 5
    $Result = Test-vmwarehostconnection -SSH $SSH -IPAddress 192.168.1.85 -VMKernelPort vmk3 -Verbose
    $Result.output
    Remove-SSHSession $SSH

    .NOTES
        Requires the POSH SSH Module

Back to Top

Clone this wiki locally