This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (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. | |
param( | |
[Parameter(Mandatory)] | |
[string[]]$Path | |
) | |
function vo ($hash) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-HumanReadableSize { | |
<# | |
.SYNOPSIS | |
Outputs a human readable version of a file size | |
.DESCRIPTION | |
This function rounds the value of the given file size to the nearest relevant | |
multiplier prefix (Gb, Mb, or Kb) | |
.INPUTS | |
long | |
.OUTPUTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#PSScriptInfo | |
.VERSION 1.0 | |
.GUID 021fb1d9-6c04-4bea-983b-92e03d14963d | |
.AUTHOR Xavier Plantefeve | |
.COPYRIGHT 2020 Xavier Plantefeve | |
.TAGS ActiveDirectory,Password | |
.LICENSEURI https://opensource.org/licenses/MIT | |
.PROJECTURI https://gist.github.com/XPlantefeve/9b1e987baf1024149edad58bb88490b2 | |
.EXTERNALMODULEDEPENDENCIES ActiveDirectory | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dirname=$(dirname $0) | |
basename=$(basename $0) | |
conffile="${basename%.*}.conf" | |
if [ -f "$dirname/$conffile" ] | |
then | |
conffile="$dirname/$conffile" | |
. "$conffile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Laziness is a great gift | |
# Every function will have the exact same definition, so we won't bother | |
# copypasting. | |
$FunctionBody = { | |
[CmdletBinding(SupportsShouldProcess)] | |
param( | |
[Parameter(Mandatory, Position = 0, ValueFromPipeline)] | |
[object[]]$inputObject | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick & dirty. Basic error checking. It works where I needed it. | |
# | |
# Documentation used: | |
# - ProcMon | |
# - https://securelink.be/blog/windows-proxy-settings-explained/ | |
# - https://docs.microsoft.com/en-us/windows/desktop/api/Winhttp/ns-winhttp-__unnamed_struct_3 | |
# - https://github.com/vbfox/proxyconf/blob/master/README.md | |
# - https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/managing-bit-flags-part-1 | |
# - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_enum | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 https://xavier.plantefeve.fr/posts/SchdTskOnEvent | |
$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 ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Profiles | |
{ | |
<# | |
.SYNOPSIS | |
Gives a list of locally saved user profiles. | |
.DESCRIPTION | |
Gets a list of locally used profiles according to the registry and | |
returns an object with information about the profile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-LastDOW { | |
<# | |
.SYNOPSIS | |
Returns the date of the last day of week you select. | |
.DESCRIPTION | |
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. |
NewerOlder