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
$queue = New-Object System.Collections.Queue | |
$wait_state = 2 | |
$job_count = 0 | |
$completed_request = @{} | |
$job_dispached = @{} | |
$throttle = 3 | |
$source_dir = "D:\" | |
$dest_dir = "E:\" |
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
<# | |
Make 20 character password with letters and numbers | |
Generate-Password 20 -NoSpecial | |
Make default length password (12) with full typable ascii set | |
Generate-Password | |
Create 20 character password using alias for shorthand | |
gpw 20 |
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
function Histogram { | |
[CmdletBinding()] | |
[Alias("hgram")] | |
param ( | |
[Parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] | |
[object[]]$Items, | |
[Parameter(Position=1)] | |
[string]$Property, | |
[ValidateRange(2,[int]::MaxValue)] | |
[int]$Scale = 40, |
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
function Random-Thing { | |
[Alias("rt")] | |
[OutputType([string])] | |
param ([switch]$FullPhrase, [switch]$XKCD) | |
begin { | |
$adjectives = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("YWJhbmRvbmVkIGFibGUgYWJzb2x1dGUgYWRvcmFibGUgYWR2ZW50dXJvdXMgYWNhZGVtaWMgYWNjZXB0YWJsZSBhY2NsYWltZWQgYWNjb21wbGlzaGVkIGFjY3VyYXRlIGFjaGluZyBhY2lkaWMgYWNyb2JhdGljIGFjdGl2ZSBhY3R1YWwgYWRlcHQgYWRtaXJhYmxlIGFkbWlyZWQgYWRvbGVzY2VudCBhZG9yYWJsZSBhZG9yZWQgYWR2YW5jZWQgYWZyYWlkIGFmZmVjdGlvbmF0ZSBhZ2VkIGFnZ3JhdmF0aW5nIGFnZ3Jlc3NpdmUgYWdpbGUgYWdpdGF0ZWQgYWdvbml6aW5nIGFncmVlYWJsZSBhamFyIGFsYXJtZWQgYWxhcm1pbmcgYWxlcnQgYWxpZW5hdGVkIGFsaXZlIGFsbCBhbHRydWlzdGljIGFtYXppbmcgYW1iaXRpb3VzIGFtcGxlIGFtdXNlZCBhbXVzaW5nIGFuY2hvcmVkIGFuY2llbnQgYW5nZWxpYyBhbmdyeSBhbmd1aXNoZWQgYW5pbWF0ZWQgYW5udWFsIGFub3RoZXIgYW50aXF1ZSBhbnhpb3VzIGFueSBhcHByZWhlbnNpdmUgYXBwcm9wcmlhdGUgYXB0IGFyY3RpYyBhcmlkIGFyb21hdGljIGFydGlzdGljIGFzaGFtZWQgYXNzdXJlZCBhc3RvbmlzaGluZyBhdGhsZXRpYyBhdHRhY2hlZCBhdHRlbnRpdmUgYXR0cmFjdGl2ZSBhdXN0ZXJlIGF1dGhlbnRpYy |
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
<# PowerShell wrapper fro the GetPerformanceInfo system call #> | |
function Get-PerformanceInfo { | |
## Liberally taken from Pinvoke.net, thank you whoever contributed that | |
## http://www.pinvoke.net/default.aspx/psapi/GetPerformanceInfo.html | |
Add-Type -Language CSharp -TypeDefinition @" | |
using System; | |
using System.Runtime.InteropServices; | |
public static class PerformanceInfo | |
{ | |
[DllImport("psapi.dll", SetLastError = true)] |
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-Service -Name TrustedInstaller | Stop-Service -Verbose | |
ii "C:\Windows\Logs\CBS\" | |
Start-Sleep -Seconds 5 | |
Get-ChildItem "C:\Windows\Logs\CBS\*" -Recurse -Force -ErrorAction SilentlyContinue | | |
Where-Object { $_.Name -ne 'CBS.Log' } | | |
Remove-Item -force -Verbose -recurse -ErrorAction Continue |
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
@echo off | |
echo. | |
echo "Stop services" | |
::pause | |
sc stop msiserver | |
sc stop TrustedInstaller | |
echo. | |
echo "Disable services" |
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
function GenAsmLoader { | |
<# | |
.Synopsis | |
Helper function for wrapping DLL assembly in PowerShell so it | |
can more easily be placed in version control and loaded within a script. | |
.DESCRIPTION | |
The ability to ship binary modules inside of a script file can be nice | |
if working in an environment that does not allow external dependencies. | |
This is a way around that by allowing you to bundle .Net DLL libraries inside | |
PowerShell code and providing a function that may be called to load the |
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
function Get-FileSize { | |
<# | |
.Synopsis | |
Gets file info, recursively if desired. | |
.DESCRIPTION | |
Enumerates files in a directory getting both the regular | |
and compressed size. The enumeration happens in a pipeline | |
function so it's memory efficient. The input parameter $Path | |
is checked for type so if you pipe the output of Get-ChildItem |
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 | |
Ternary operation for PowerShell with terse | |
parameter aliases. Meant to be used from pipeline. | |
.Example | |
gci -Recurse | >> {$_.PSIsContainer} "Directory" "File" | |
.Example | |
1..10 | >> {($_ % 2) -eq 0} "Even" "Odd" | |
.Example | |
# Pass through numbers greater than 0 or print 0 |