This file contains hidden or 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
$keys = @{ | |
'1'='' ; '2'='[abc]'; '3'='[def]' ; | |
'4'='[ghi]' ; '5'='[jkl]'; '6'='[mno]' ; | |
'7'='[pqrs]'; '8'='[tuv]'; '9'='[wxyz]'; | |
} | |
$nums = '76937' | |
$pattern = foreach ($char in $nums.GetEnumerator()) |
This file contains hidden or 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
⍝ This is in a workspace, default namespace | |
⍝ created by )Ed ○InvokeAplExpression | |
⍝ Then exported as a Microsoft .Net Assembly | |
⍝ With the Isolation Mode dropdown set to | |
⍝ 'Each assembly attempts to use local bridge and interpreter libraries' | |
⍝ pre-req: make a project folder e.g. "D:\m\" and copy file | |
⍝ System.Management.Automation.dll from the .Net GAC into it. | |
⍝ PS> Copy-Item -Path ([psobject].Assembly.Location) -Destination 'd:\m\' -Verbose |
This file contains hidden or 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
# Parameters | |
param( | |
[string] $ComputerList = $(Join-Path -Path $PSScriptRoot -ChildPath "computers.txt"), # Path to the list of computers | |
[string] $ReportPath = $(Join-Path -Path $PSScriptRoot -ChildPath "report.csv"), # Path to the report to output | |
[switch] $DeleteFolder = $false # Whether to delete MININT or not | |
) | |
Get-Content $ComputerList | ForEach-Object { | |
$result = @{ |
This file contains hidden or 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
<# | |
.Synopsis | |
Tests a string against Active Directory default password complexity requirements | |
.DESCRIPTION | |
Checks password length, and whether it meets 3 out of 4 of the following: | |
- Lowercase character a-z | |
- Uppercase character A-Z | |
- Digit 0-9 | |
- Special character !,#,-, etc. |
This file contains hidden or 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
# Map URLs to Internet Explorer Security Zones via PowerShell | |
$csSource = @' | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
public class IEZones | |
{ |
This file contains hidden or 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
$ExecutionContext.InvokeCommand.CommandNotFoundAction = { | |
param($Name,[System.Management.Automation.CommandLookupEventArgs]$CommandLookupArgs) | |
$CommandLookupArgs.CommandScriptBlock = { | |
if ($CommandLookupArgs.CommandName -match '(?<binary>1[10]*)b$') | |
{ | |
[convert]::ToInt32($matches['binary'], 2) | |
} |
This file contains hidden or 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
# Automates Outlook | |
# - searches the Inbox for Thawte | |
# 'your SSL certificate has been approved' messages | |
# - extracts the certificate to disk with a useful filename | |
# - deletes the emails | |
$VerbosePreference = 'continue' | |
$OutputFolder = '\\server\share\SSL Cert Deliveries\' |
This file contains hidden or 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
# C# runs in ~0.5 seconds. | |
# powershell commented out below runs in ~23 seconds. | |
# correct answer is 567 | |
Add-Type @' | |
using System; | |
public class MyType1 | |
{ | |
public long crunch() { |
This file contains hidden or 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
$in = @' | |
5 9 2 8 | |
9 4 7 3 | |
3 8 6 5 | |
'@ -split "`r?`n" | |
$in | ForEach-Object { | |
# part 1 was easy, split string, measure the max and min, then find the difference | |
# part 1 # $minmax = -split $_ | Measure-Object -Minimum -Maximum |