Skip to content

Instantly share code, notes, and snippets.


Xavier Plantefève XPlantefeve

View GitHub Profile
View Import-BEncoded.ps1
# (very) quick and (very) dirty bencoding converter.
# I actually did not now what bencoding was and reverse engineered the few
# files I needed information about.
function vo ($hash) {
View SubfoldersSizeReport.ps1
function Get-HumanReadableSize {
Outputs a human readable version of a file size
This function rounds the value of the given file size to the nearest relevant
multiplier prefix (Gb, Mb, or Kb)
View Reset-PwdLastSet.ps1
.GUID 021fb1d9-6c04-4bea-983b-92e03d14963d
.AUTHOR Xavier Plantefeve
.COPYRIGHT 2020 Xavier Plantefeve
.TAGS ActiveDirectory,Password
XPlantefeve / restoreOVHCloudArchive
Last active Sep 4, 2019
Restore files from OVH Cloud Archive
View restoreOVHCloudArchive
dirname=$(dirname $0)
basename=$(basename $0)
if [ -f "$dirname/$conffile" ]
. "$conffile"
XPlantefeve / filter_to_ldapfilter.ps1
Last active Jun 11, 2020
getting Active Directory info through ADSI
View filter_to_ldapfilter.ps1
# Quick and very dirty PS filter to LDAP filters translation
function Format-LdapEscaped ($string,[switch]$wildcard) {
Switch -Regex ($string.Trim()) {
'^"(?<str>.*)"$' { $string = $Matches.str -replace '`"','"' }
"^'(?<str>.*)'$" { $string = $Matches.str -replace "''","'" }
$string = $string -replace '\\5c','\'
$string = $string -replace '\\00','NUL'
XPlantefeve / Do-Something.ps1
Last active Feb 14, 2019
Do-Something, the lazy typist way
View Do-Something.ps1
# Laziness is a great gift
# Every function will have the exact same definition, so we won't bother
# copypasting.
$FunctionBody = {
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
XPlantefeve / WinHttpProxySettings.ps1
Last active Feb 10, 2019
netsh winhttp * proxy, but in PowerShell
View WinHttpProxySettings.ps1
# Quick & dirty. Basic error checking. It works where I needed it.
# Documentation used:
# - ProcMon
# -
# -
# -
# -
# -
View CreateSchdTskOnEvent.ps1
# The following is an example, it's not a function, it's not meant to be run
# as is, I just wrote it to show how creating a scheduled tak on an event
# can be done in PowerShell. I wrote a small post about how it came to be, that
# can be read at
$class = Get-cimclass -ClassName MSFT_TaskEventTrigger -Namespace root/Microsoft/Windows/TaskScheduler
$trigger = $class | New-CimInstance -ClientOnly
$trigger.Enabled = $true
$trigger.Subscription = '<QueryList><Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"><Select `
View registryHives.ps1
Function Get-Profiles
Gives a list of locally saved user profiles.
Gets a list of locally used profiles according to the registry and
returns an object with information about the profile.
XPlantefeve / Get-LastDOW.ps1
Created Jul 13, 2017
Get date for last <day of week>
View Get-LastDOW.ps1
function Get-LastDOW {
Returns the date of the last day of week you select.
Get-LastDOW will return the date of the last day of the week you select,
up to one week in the past (between one week ago and yesterday). Useful,
as an example, to search in logs for events only happening once a week.