Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Created July 23, 2019 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steviecoaster/398544abfd1e6834888258e283d292fe to your computer and use it in GitHub Desktop.
Save steviecoaster/398544abfd1e6834888258e283d292fe to your computer and use it in GitHub Desktop.
Query size of a chocolatey log
function Get-ChocoLogSize {
<#
.SYNOPSIS
Returns the size of the chocolatey.log file in MB
.PARAMETER Computername
The system to query. Defaults to the local COMPUTERNAME
.EXAMPLE
Get-ChocoLogSize
.EXAMPLE
Get-ChocoLogSize -Computername Wrkstn02
#>
[cmdletBinding()]
param(
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
[String[]]
$Computername = $env:COMPUTERNAME
)
$params = @{
Computername = $Computername
Scriptblock = { [Math]::Round(((Get-ChildItem "$env:ChocolateyInstall\logs\chocolatey.log").Length /1MB),2) }
}
Invoke-Command @params
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment