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
Get-CimInstance -ClassName SoftwareLicensingProduct | | |
Where-Object {$_.ApplicationId -eq "55c92734-d682-4d71-983e-d6ec3f16059f" -and $_.PartialProductKey } | | |
Select-Object Name, | |
@{Name="LicenseStatus"; Expression = { | |
switch ($_.LicenseStatus) { 0 { "Unactivated"} | |
1 { "Activated" } | |
default { "unknown" } | |
} } } |
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 = '1212' | |
# Just regex out the characters which are the same as the following character, with a backreference | |
# convert to int, and sum them. Handle the wraparound condition by adding the first character | |
# to the end of the string | |
function day1 { | |
param($s) | |
$s = $s + $s[0] |
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 |
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
# 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
$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
# 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
<# | |
.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
# 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 = @{ |
OlderNewer