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 UnixEpoch | |
Dim utc_now, t_diff, objWMIService, colItems, item | |
Set objWMIService = GetObject("winmgmts:" _ | |
& "{impersonationLevel=impersonate}!\\.\root\cimv2") | |
'Get UTC time string | |
Set colItems = objWMIService.ExecQuery("Select * from Win32_UTCTime") | |
For Each item In colItems | |
If Not IsNull(item) Then |
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 | |
Gets directory sizes quickly. | |
.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 | |
into the function it will use the FullName parameter as the path. | |
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
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
namespace NativeHelpers | |
{ | |
public static class NativeHelpers | |
{ | |
// |
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 Dedupe { | |
param ( | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelinebyPropertyName=$false, | |
Position=0)] | |
$obj, | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$false, | |
ValueFromPipelinebyPropertyName=$false, |
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
<# | |
Simple WPF dashboard script with functions mapped to buttons. | |
Uses command pattern to map button clicks to PowerShell script | |
blocks. | |
How it kinda works: | |
The WPF UI for PowerShell idea I got from here: | |
https://foxdeploy.com/2015/04/16/part-ii-deploying-powershell-guis-in-minutes-using-visual-studio/ |
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 script will show who is listed as a group manager and who has | |
rights to modify the group members. Just populate the $groupNames | |
list with group names, wildcards are allowed. | |
#> | |
$groupNames = @( | |
"Some Group Name" | |
) | |
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
#Requires -Version 4 | |
#Load Types | |
{ | |
if (-not ([System.Management.Automation.PSTypeName]'CompressHelper').Type) { | |
Add-Type -Language CSharp -TypeDefinition @" | |
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
public static class CompressHelper { |
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
<?xml version="1.0" encoding="utf-16"?> | |
<StorableColorTheme xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<Keys> | |
<string>ErrorForegroundColor</string> | |
<string>ErrorBackgroundColor</string> | |
<string>WarningForegroundColor</string> | |
<string>WarningBackgroundColor</string> | |
<string>VerboseForegroundColor</string> | |
<string>VerboseBackgroundColor</string> | |
<string>DebugForegroundColor</string> |
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
#Requires -Version 3 | |
# Transforms objects from LDIF formatted file, parses file into PowerShell | |
# objects, then does string replace operations on all properties. | |
# Good Luck | |
# Works starts around line 170 | |
#################################################################### | |
## Functions ## | |
#################################################################### |
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 Make-UniquePath { | |
param([string]$path) | |
$ptemp = $path | |
$inc = 1; | |
$ext = [IO.Path]::GetExtension($path) | |
while (Test-Path $ptemp) { | |
$tmp_ext = [String]::Concat("-",$inc.ToString("D2"),$ext) | |
if ([String]::IsNullOrEmpty($ext)) { | |
$ptemp = [String]::Concat($path,$tmp_ext) |