Skip to content

Instantly share code, notes, and snippets.

View XPlantefeve's full-sized avatar

Xavier Plantefève XPlantefeve

View GitHub Profile
Topic: NBA All Stars
Owners: Foo Owners
Users: User 1
Users: User 2
Topic: NFL MVPs
Owners: Bar Owners
Users: Tony Stark
Users: Mitch Hedberg
Users: Someone Else
Topic: NBA MVPs
function Get-FolderSizeRC($Path) {
if ( robocopy $Path c:\dummy /e /r:0 /w:0 /b /BYTES /nfl /ndl /np /njh /l | ? { $_ -match 'Bytes :\s*(?<size>\S+)' } ) { return [int64]$Matches.size }
}
function Get-FolderSizePS($Path) {
return ( ls -Recurse -Path $Path -Force | measure -Property length -Sum ) | select -ExpandProperty Sum
}
function test($Path) {
Write-Host -Object "Testing $Path" -ForegroundColor Cyan
@XPlantefeve
XPlantefeve / New-ExcelDocument.ps1
Created June 15, 2016 11:44
Barebone excel creation + CSV import method. Basis for further work.
#region ExcelFunctions
function Get-NormalizedPath ( $Path ) {
if ( ( Split-Path $Path ) -match '^(\.|)$' ) {
$Path = Join-Path -Path ( Get-Location ) -ChildPath ( Split-Path -Path $Path -Leaf )
}
return $Path
}
$MethodImportCSVtoSheet = {
@XPlantefeve
XPlantefeve / MaintenanceWindowFunctions.ps1
Last active June 13, 2016 09:15
A couple of quickly done functions to handle local CCM maintenance windows.
<#
MIT License
Copyright (c) 2016 Xavier Plantefeve
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@XPlantefeve
XPlantefeve / LICENSE.txt
Last active April 12, 2022 10:02
Powershell Gist management CMDlets
MIT License
Copyright (c) 2016 Xavier Plantefeve
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@XPlantefeve
XPlantefeve / New-Timer.ps1
Last active May 30, 2016 08:17
Creates a timer that display a progressbar and the estimated remaining time.
<#
.Synopsis
Creates a timer with display
.DESCRIPTION
Creates a timer that writes the progress of the current action and the estimated remaining time.
Suppose you have $Items, an array of items to process.
First, you create a timer initialized to the number of items in the array:
$MyTimer = New-Timer -TotalItems $Items.count -Activity 'Processing items'
# Answer to http://powershell.org/wp/2016/03/05/2016-march-scripting-games-puzzle/
Function Get-HumanReadableSize($size) {
If ( $size -lt 1KB) { Return $size }
ElseIf ( $size -lt 1MB) { Return "$([math]::Round(($size / 1KB),2))Kb" }
ElseIf ( $size -lt 1GB) { Return "$([math]::Round(($size / 1MB),2))Mb" }
ElseIf ( $size -lt 1TB) { Return "$([math]::Round(($size / 1MB),2))Gb" }
Else { Return "$([math]::Round(($size / 1TB),2)) TB" }
}
@XPlantefeve
XPlantefeve / keybase.md
Created March 18, 2016 05:44
Keybase proof

Keybase proof

I hereby claim:

  • I am Xplantefeve on github.
  • I am xplantefeve (https://keybase.io/xplantefeve) on keybase.
  • I have a public key whose fingerprint is BBA5 AAF0 DC6E 481C 091E A57D 8230 1914 C28F 3C6E

To claim this, I am signing this object:

<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
<#
.Synopsis
Gets uptime information
.EXAMPLE
Get-Uptime -ComputerName URANUS
.INPUTS
String[]
.OUTPUTS
CUSTOM.UptimeInfo
.NOTES