Skip to content

Instantly share code, notes, and snippets.

Mathias R. Jessen IISResetMe

  • Booking.com
  • Netherlands
Block or report user

Report or block IISResetMe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@IISResetMe
IISResetMe / Log-ChromeExtension.ps1
Created Jun 13, 2019
Discover chrome extensions and log information about them to event log
View Log-ChromeExtension.ps1
<#
.SYNOPSIS
Inventory Chrome Extension information and dump the info to the Windows Event Log
.DESCRIPTION
This is a simplified adaptation of zsattler's Set-ChromeExtensions.ps1 which writes extension info to a WMI namespace for SCCM to pick up
This version writes the information to a custom Windows Event Log instead, easily picked up for WEF or similar log forwarding tools.
Original script: https://github.com/zsattler/PowerShell/blob/master/Set-ChromeExtensions/Set-ChromeExtensions.ps1
Original blog post: https://zsattler.wordpress.com/2017/02/27/chrome-extension-inventory-for-sccm/
View ConditionalRegex.koan.ps1
using module PSKoans
[Koan(Position = 666)]
param()
Describe "Regex" {
It "breaks your brainz" {
$res = __ -match '^(?<pp>a )must-have tool(?(pp)|s)'
$res |Should -Be $true
}
@IISResetMe
IISResetMe / PSTextEncodingConverter.class.ps1
Created May 28, 2019
System.Text.Encoding converter to easy argument conversion
View PSTextEncodingConverter.class.ps1
using namespace System.Management.Automation
using namespace System.Text
class PSTextEncodingConverter : PSTypeConverter {
hidden
[hashtable]
$ConversionTable = @{
'ASCII' = [System.Text.Encoding]::ASCII
'ANSI' = [System.Text.Encoding]::ASCII
@IISResetMe
IISResetMe / Sort-Reverse.ps1
Created May 27, 2019
Array Reversal in the pipeline
View Sort-Reverse.ps1
# terrible
function Sort-VarReverse {
# sorting rank = max
$rank = [int]::MaxValue
$input |Sort-Object {
# decrement $rank in parent scope, reversing the input order
(--(Get-Variable rank -Scope 1).Value)
}
}
View VisitorKittenz.ps1
using namespace System.Collections.Generic
using namespace System.Management.Automation.Language
#region AstVisitor
class VisitorKitten : ICustomAstVisitor
{
[int]GetDepth([Ast]$ast){
$temp = $ast
$count = 0
while($temp -and $temp -ne $temp.Parent){
View Get-DistinctUnion.ps1
function Get-DistinctUnion
{
param(
[array]$Source,
[array]$Other
)
$temp = [System.Collections.Generic.HashSet[object]]::new($Source)
$temp.UnionWith($Other)
@IISResetMe
IISResetMe / GetFileTime.ps1
Last active Apr 24, 2019
Fast acquisition of LastWriteTime attribute value of files via Kernel32.dll
View GetFileTime.ps1
$kernel32,$filetime = Add-Type -TypeDefinition @'
// Partial port of the C# example at
// https://www.pinvoke.net/default.aspx/kernel32.getfiletime
//
using System;
using System.Runtime.InteropServices;
public class Kernel32wrappers {
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
@IISResetMe
IISResetMe / Get-ChildItemDeep.ps1
Created Apr 12, 2019
Get-ChildItem -Depth for PS 4.0
View Get-ChildItemDeep.ps1
function Get-ChildItemDeep
{
param(
[Parameter(ParameterSetName='Items', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string[]]
${Path},
[Parameter(Position=1)]
[string]
${Filter},
View wildcards.ps1
function Search-Stuff
{
param([string]$String)
$Data = 'lol', 'lol123', '123lol', '123lol123'
$Filter = if([WildcardPattern]::ContainsWildcardCharacters($string)){
{ $_ -like $string }
} else {
{ $_ -eq $string }
View CreateServicePInvoke.ps1
Add-Type '
using System;
using System.Runtime.InteropServices;
public class advapi32 {
[DllImport("advapi32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr CreateService(
IntPtr hSCManager,
string lpServiceName,
string lpDisplayName,
uint dwDesiredAccess,
You can’t perform that action at this time.