Skip to content

Instantly share code, notes, and snippets.

View Nora-Ballard's full-sized avatar

Nora Ballard Nora-Ballard

View GitHub Profile
function Get-AlphaRange([string]$Range)
{
$Alphabet = @('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
$AlphabetIndex = @{'a' = 0 ;'b' = 1 ;'c' = 2 ;'d' = 3 ;'e' = 4 ;'f' = 5 ;'g' = 6 ;'h' = 7 ;'i' = 8 ;'j' = 9 ;'k' = 10 ;'l' = 11 ;'m' = 12 ;'n' = 13 ;'o' = 14 ;'p' = 15 ;'q' = 16 ;'r' = 17 ;'s' = 18 ;'t' = 19 ;'u' = 20 ;'v' = 21 ;'w' = 22 ;'x' = 23 ;'y' = 24 ;'z' = 25}
if ($Range -match '[a-z]\.{2}[a-z]')
{
$RangeStart = $AlphabetIndex[$Range.split('..')[0]]
$RangeEnd = $AlphabetIndex[$Range.split('..')[2]]
if ($RangeStart -lt $RangeEnd)
function New-SparseFile
{
param(
[string]$filepath,
[long]$sizeInBytes,
[switch]$passthrough
)
if (test-path $filepath)
{
throw "File '$filepath' already exists."
Function Touch-File
{
param(
[Parameter(Mandatory=$True)]
$Path
)
if(Test-Path $Path)
{
Set-ItemProperty -Path $Path -Name LastWriteTime -Value $(get-date) -PassThru | Get-Item
}
function New-FolderWatcher
{
param(
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)]
$Path,
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$True)]
[hashtable] $Events ,
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$True)]
$MessageData = "",
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$True)]
function Get-SCCMSiteMode($ComputerName)
{
if ( $(Get-Service -Name CcmExec -ComputerName $ComputerName -ErrorAction SilentlyContinue) )
{
try { $CCM_ClientSiteMode = Get-WmiObject -Namespace 'ROOT\ccm' CCM_ClientSiteMode -ComputerName $ComputerName -EA SilentlyContinue }
catch { $CCM_ClientSiteMode = $NULL}
if ($CCM_ClientSiteMode)
{
Invoke-WmiMethod -ComputerName $ComputerName -Path win32_process -Name create -ArgumentList "gpupdate /target:Computer /force"
function Repair-SCCMHttpStatus($ComputerName,$DesiredHttpsState = 0x0000005f)
{
$WhatIf = $false
$HTTPSStates = @{
'0' = 'Mixed mode'
'31' = 'Native mode'
'63' = 'Native mode, CRL'
'95' = 'Native mode, FALLBACK'
'127' = 'Native mode, CRLANDFALLBACK'
function Repair-RemoteRegistryService($ComputerName)
{
# Tries to Start the Remote Registry Service, and returns true or false if it is running.
Get-Service -ComputerName $ComputerName -Name RemoteRegistry -ErrorAction SilentlyContinue | Start-Service -ErrorAction SilentlyContinue
$RemoteRegistrySvc = Get-Service -ComputerName $ComputerName -Name RemoteRegistry -ErrorAction SilentlyContinue
If ($RemoteRegistrySvc.Status -eq 'Running') { $true }
else
{
$false
$LOCAL_ADMINISTRATORS = [System.Security.Principal.NTAccount] "Administrators"
$FS_RIGHT_LIST = 'ListDirectory, Traverse'
$FS_RIGHT_READ = 'Read'
$FS_RIGHT_MODIFY = 'Modify'
$FS_RIGHT_CREATE = 'CreateFiles, CreateDirectories'
$This_Folder_Subfolders_Files = @('ContainerInherit, ObjectInherit', 'none')
$Subfolders_Files_Only = @('ContainerInherit, ObjectInherit', 'InheritOnly')
$Subfolders_Only = @('ContainerInherit', 'InheritOnly')
@Nora-Ballard
Nora-Ballard / Rococopy.bat
Created February 15, 2014 13:45
Robocopy wrapper for migrating volumes in two phases; an initial online bulk copy, followed by an offline differential copy. Used for migrating large folders/volumes with minimal downtime. Requires handle.exe, psfile.exe, and robocopy.exe.
@ECHO OFF
SET SCRIPTPATH=%~dp0
setlocal ENABLEDELAYEDEXPANSION
:: ElevationCheck TODO: ADD OS Check/Disable for 2003
::whoami /groups | find "S-1-16-12288" > nul
::if "%errorlevel%"=="0" (
:: echo Running as elevated user. Continuing script.
:: echo.
::) else (