Skip to content

Instantly share code, notes, and snippets.

View devynspencer's full-sized avatar
:octocat:

Devyn Spencer devynspencer

:octocat:
View GitHub Profile
@devynspencer
devynspencer / .gitconfig
Created December 20, 2019 17:33
Basic gitconfig with useful aliases
# This is Git's per-user configuration file.
[user]
name = Devyn Spencer
email = devynspencer@users.noreply.github.com
[alias]
co = checkout
br = branch
ci = commit
st = status
ll = log
# Given a list of users and computer names, add the SAM account name to each
@{
Users = @(
@{
Name = "Joe Joesworthy"
ComputerName = "P9XYZ123"
}
@{
Name = "Seandog Millionaire"
ComputerName = "MJXYZ123"
workflow {
param(
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByValue)]
$ComputerName,
[pscredential] $Credential = "$env:USERDOMAIN\$env:USERNAME",
[switch] $All,
[switch] $Configuration,
[switch] $Users # sessions, user profiles, accounts, groups
params ["_required1", "_required2", ["default1", "value"], ["default2", 5], ["default3", west]]
private ["_var1", "_var2", "_var3", "_var4"]
// header
_Zen_stack_Trace = ["Zen_ArrayAppend", _this] call Zen_StackAdd;
if !([_this, [["ARRAY"], ["VOID"], ["VOID"], ["VOID"], ["VOID"], ["VOID"], ["VOID"]], [], 2] call Zen_CheckArguments) exitWith {
call Zen_StackRemove;
};
// execute something here
function Repair-HomeDirectoryAcl {
Param(
# TODO: cast this as a file-object / review PowerShell idioms for working with directories
[Parameter(Mandatory, ValueFromPipeline) # TODO: , ValueFromPipelineByProperty)]
[string] $Path,
[switch] $Recurse
)
process {
@devynspencer
devynspencer / Functions.ps1
Last active November 17, 2016 06:03
Useful PowerShell functions, for eventual aggregation into a utilities module or similar.
function ConvertTo-BooleanString ($value) {
return [System.Convert]::ToBoolean($value).ToString()
}
Function New-Something {
[CmdletBinding()]
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True)]
[string[]] $ComputerName
)
begin {
}
<#
--------------
WSUS Installer v1
--------------
by Trevor Jones
This script installs and configures WSUS on a Windows 2012 server.
You have the option to use WID, Local SQL Express or an existing SQL Server.
If you choose Local SQL Express it will be downloaded and installed for you with a default configuration.
Report Viewer 2008 is also optionally installed, it is required to view WSUS reports.
@devynspencer
devynspencer / Get-LastUpdated.ps1
Created September 1, 2016 22:34
Get the installation time for the last successful update to a server.
foreach ($Server in $servers) {
$key = “SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install”
$keytype = [Microsoft.Win32.RegistryHive]::LocalMachine
$RemoteBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($keytype,$Server)
$regKey = $RemoteBase.OpenSubKey($key)
$KeyValue = $regkey.GetValue(”LastSuccessTime”)
$System = (Get-Date -Format "yyyy-MM-dd hh:mm:ss")
if ($KeyValue -lt $System) {
Write-Host " "
@devynspencer
devynspencer / script_deployment.bat
Created August 26, 2016 13:19
Example batch file to run a powershell script without having to fuck with the system execution policy
@echo off
Powershell -noprofile -executionpolicy bypass -file "C:\scripts\script.ps1"