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
# 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
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: |
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
#requires -version 4.0 | |
Function Convert-CSVtoXLS { | |
<# | |
.SYNOPSIS | |
This function converts a CSV file to an Excel workbook. | |
.DESCRIPTION | |
Convert-CSVtoXLS converts a csv file to a Excel workbook. | |
The first line of the CSV file is turned into a filtering header. | |
Excel must be installed on the computer. |
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
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 |
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 | |
) |
NewerOlder