Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias R. Jessen IISResetMe

  • Booking.com
  • Netherlands
View GitHub Profile
View DontTrustProgress.ps1
function Fake-Progress
{
$PSDefaultParameterValues['Write-Progress:Activity']='Making stuff up'
Write-Progress -Status 'Starting out' -PercentComplete 5
10..45|%{
Write-Progress -Status 'Doing stuff' -PercentComplete $_
Start-Sleep -Milliseconds 100
}
@IISResetMe
IISResetMe / ConvertFrom-EventLogRecord.ps1
Last active Jul 28, 2020
Convert EventData fields from windows event log records to objects
View ConvertFrom-EventLogRecord.ps1
function ConvertFrom-EventLogRecord
{
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[System.Diagnostics.Eventing.Reader.EventLogRecord[]]
$InputEvent,
[Parameter(Mandatory=$true,Position=1)]
[ValidateNotNullOrEmpty()]
[string[]]
@IISResetMe
IISResetMe / Get-MachineSID.ps1
Created Dec 30, 2014
PsGetSid local machine SID implementation in PowerShell
View Get-MachineSID.ps1
function Get-MachineSID
{
param(
[switch]
$DomainSID
)
# Retrieve the Win32_ComputerSystem class and determine if machine is a Domain Controller
$WmiComputerSystem = Get-WmiObject -Class Win32_ComputerSystem
$IsDomainController = $WmiComputerSystem.DomainRole -ge 4
View Invoke-RegexTerror.ps1
function Invoke-RegexTerror
{
[CmdletBinding(DefaultParameterSetName = 'ToBeOrNotToBe')]
param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[int]$Count,
[Parameter(ParameterSetName = 'ToBeOrNotToBe')]
[switch]$Shakespeare,
@IISResetMe
IISResetMe / ConvertTo-Object.ps1
Last active Jun 22, 2020
Quick and dirty regex-based text-to-object parsing using named expressions groups and $Matches
View ConvertTo-Object.ps1
function ConvertTo-Object {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[AllowEmptyString()]
[string[]]$InputString,
[Parameter(Mandatory=$true,ValueFromRemainingArguments=$true)]
[string[]]$Pattern
)
View NotMatchAny.ps1
function NotMatchAny {
param(
[Parameter(Mandatory)]
[string[]]$Excludes,
[string]$Property,
[switch]$First,
[switch]$Last
View XmlFileTreeGenerators.ps1
function Get-XmlFileTreeAppend
{
param(
[Parameter(ParameterSetName='Path', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string[]]
${Path},
[Parameter(ParameterSetName='LiteralPath', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[Alias('PSPath')]
[string[]]
View s_client.ps1
using namespace System.Net.Sockets
using namespace System.Net.Security
using namespace System.Security.Cryptography.X509Certificates
function ConvertFrom-X509Certificate {
param(
[Parameter(ValueFromPipeline)]
[X509Certificate2]$Certificate
)
View Get-ADLockedOutUser.ps1
function Get-ADLockedOutUser {
[CmdletBinding(DefaultParameterSetName = 'MultiDC')]
param(
[Parameter(Mandatory = $false, ParameterSetName = 'MultiDC')]
[string[]]$DCFilter = @('*'),
[Parameter(Mandatory = $true, ParameterSetName = 'PDCOnly')]
[switch]$PDCOnly
)
View lcg.class.ps1
class LCG
{
hidden [long]
$factor = 1140671485
hidden [long]
$offset = 12820163
hidden [long]
$modulus = 16777216
You can’t perform that action at this time.