Skip to content

Instantly share code, notes, and snippets.

View ScriptAutomate's full-sized avatar
:shipit:
Automating All The Things

Derek Ardolf ScriptAutomate

:shipit:
Automating All The Things
View GitHub Profile
@ScriptAutomate
ScriptAutomate / Sec360-Demo-Code.ps1
Last active May 19, 2016 02:58
DEMO COMMANDS USED IN SECURE360 PRESENTATION (05/18/15)
<#
Links:
https://github.com/ScriptAutomate/AuditTools
https://halfwaytoinfinite.com/
https://twitter.com/ScriptAutomate
https://secure360.org
#>
break # To prevent accidental example script execution
@ScriptAutomate
ScriptAutomate / Create-ADAuditable-LocalAdmins.ps1
Last active November 9, 2016 09:54
Create AD Auditable Local Admins
break # To prevent accidental example script execution
Import-Module ActiveDirectory
# Create all groups for serverset1
$FirstServerSet = Get-Content "serverset1.txt"
$FirstOU = "OU=Loc1,OU=Groups,DC=contoso,DC=com"
foreach ($Server in $FirstServerSet) {
New-ADGroup "$Server.AdminGroup" -Path $FirstOU -GroupScope Global
}
@ScriptAutomate
ScriptAutomate / SMBShare-Demo.ps1
Last active August 29, 2015 14:20
Create Shares with PowerShell
break # To prevent accidental example script execution
# Share/NTFS Permissions
$ComputerName = Get-Content c:\temp\serverlist.txt
Invoke-Command -ComputerName $ComputerName -Credential $Credential -ScriptBlock {
# Create the share, give service account permissions
if ((Test-Path "C:\test") -and !(Get-SmbShare test$ -ErrorAction SilentlyContinue)) {
# Creating share
New-SmbShare –Name test$ `
–Path C:\test `
-FullAccess CONTOSO\serviceaccount1 `
@ScriptAutomate
ScriptAutomate / Set-ServiceStartupMode.ps1
Created April 29, 2015 11:53
Set-ServiceStartupMode [For PowerShell v2+]
# For PowerShell v2; Otherwise, Set-Service cmdlet exists in v3+ with -StartupType parameter!
function Set-ServiceStartupMode {
[CmdletBinding()]
param (
[String[]]$ComputerName,
[String]$ServiceName,
[ValidateSet("Boot","System","Automatic","Manual","Disabled")]
[String]$StartupMode,
[Parameter(Mandatory=$False)]
[Management.Automation.PSCredential]$Credential
@ScriptAutomate
ScriptAutomate / WindowsContainers-Demo.ps1
Last active October 16, 2015 03:46
Demo code used in Twin Cities PowerShell Automation presentation
# What I followed to do containers (Microsoft's Quickstart Guide):
# https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quickstart
break
# Run on Server Core 2016 TP3
Start-Process PowerShell -Verb runAs
mkdir c:\scripts
wget -uri http://aka.ms/setupcontainers -OutFile c:\scripts\containersetup.ps1
c:\scripts\containersetup.ps1 #This script took ~50 minutes, but downloads/installs Docker too
@ScriptAutomate
ScriptAutomate / WMI-CIM-CodeExamples.ps1
Created September 10, 2015 15:43
Examples of Using WMI/CIM Cmdlets
break #To prevent accidental execution of all commands
# WMI cmdlets: Work against anything, where DCOM RPC dynamic port range is available
# CIM cmdlets: Exist in PowerShell v3 and up, can use DCOM or WSMAN. Can have CimSessions. Microsoft going forward.
$Creds = Get-Credential
Get-WmiObject -Class win32_computersystem
Get-WmiObject -Class win32_computersystem -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -ComputerName server1 -Credential $Creds
$Session = New-CimSession -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -CimSession $Session
Get-CimSession
@ScriptAutomate
ScriptAutomate / ubuntu-1604-jea-lab-setup.sh
Last active July 28, 2018 19:47
Secure360: Preparing Ubuntu 16.04 dev desktop for presentation
exit #prevent accidental run of script
# App versions
PACKERVER='0.10.1'
VAGRANTVER='1.8.5'
CHEFDKVER='0.17.17'
CHEFDKRUBYVER='2.1.0'
CHEFDKRUBYPATH="export PATH=\"$PATH:/home/dscripter/.chefdk/gem/ruby/$CHEFDKRUBYVER/bin\""
# Install Git and Unzip
@ScriptAutomate
ScriptAutomate / jekyll-dev-ubuntu.sh
Last active August 29, 2018 22:28
Basic code for setting up Jekyll locally
# Initial VM updates
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
# Vars for download/install endpoints
VSCODE='vscode.deb'
CHEFDK='chefdk.deb'
VSCODEURL='https://go.microsoft.com/fwlink/?LinkID=760868'
CHEFDKURL='https://packages.chef.io/files/stable/chefdk/3.1.0/ubuntu/18.04/chefdk_3.1.0-1_amd64.deb'
# Dev tool downloads
@ScriptAutomate
ScriptAutomate / yahoo-stock.py
Created July 28, 2018 22:34
Basic stock worth via Yahoo API
import mechanicalsoup
import argparse
def get_ticker():
"""
Grab user supplied arguments using the
argparse library.
"""
parser = argparse.ArgumentParser(
@ScriptAutomate
ScriptAutomate / quadratic-formula.py
Last active August 3, 2018 15:36
Quadratic Formula
import argparse
"""
Quadratic equation root calculator
"""
def get_arguments():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,