Skip to content

Instantly share code, notes, and snippets.

:octocat:
Learning.

Devyn Spencer devynspencer

Block or report user

Report or block devynspencer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Get-Inventory.ps1
workflow {
param(
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByValue)]
$ComputerName,
[pscredential] $Credential = "$env:USERDOMAIN\$env:USERNAME",
[switch] $All,
[switch] $Configuration,
[switch] $Users # sessions, user profiles, accounts, groups
View Red_FunctionTemplate.sqf
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
View Repair-HomeDirectories.ps1
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 Nov 17, 2016
Useful PowerShell functions, for eventual aggregation into a utilities module or similar.
View Functions.ps1
function ConvertTo-BooleanString ($value) {
return [System.Convert]::ToBoolean($value).ToString()
}
View CmdletTemplate.ps1
Function New-Something {
[CmdletBinding()]
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True)]
[string[]] $ComputerName
)
begin {
}
View deploy-wsus.ps1
<#
--------------
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 Sep 1, 2016
Get the installation time for the last successful update to a server.
View Get-LastUpdated.ps1
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 Aug 26, 2016
Example batch file to run a powershell script without having to fuck with the system execution policy
View script_deployment.bat
@echo off
Powershell -noprofile -executionpolicy bypass -file "C:\scripts\script.ps1"
@devynspencer
devynspencer / iptables_yum.md
Last active Jun 15, 2016
Finding blocked packages repositories from iptables logs, then creating a manageable list for to distribute to other hosts.
View iptables_yum.md
[dspencer@poseidon ~]$ cat /tmp/iptables_yum.txt | awk '{ print $10}' |\
  sed 's/DST=//' | xargs -n1 host | awk '{ print $5 }' | grep -v NXDOMAIN | sort -u

ajax.vcu.edu.
archive.linux.duke.edu.
boa.wallawalla.edu.
cork.umd.edu.
deepthought.gtlib.gatech.edu.
dl01.fedoraproject.org.
@devynspencer
devynspencer / ansible-github.yml
Last active Apr 24, 2019
Example playbook for cloning a private git repository with Ansible.
View ansible-github.yml
---
hosts: all
tasks:
- name: add github ssh key
copy: >
src=files/id_rsa.github
dest=/root/.ssh/id_rsa.github
owner=root
group=root
You can’t perform that action at this time.