Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
$osVersion = (Get-WmiObject Win32_OperatingSystem).Version
$os = (Get-WmiObject "Win32_OperatingSystem")
switch ([version]$osVersion) {
{($_ -ge [version]"6.0") -AND ($_ -le [version]"6.0.6001")} {
Write-Output "OS is Vista or 2008"
}
{($_ -eq [version]"6.1.7600")} {
Write-Output "OS is Win7 or Server 2008 R2 (NON-SP1)"
}
{($_ -ge [version]"6.1.7601") -AND ($_ -lt [version]"6.2")} {
@lantrix
lantrix / ad_unlock_reset.ps1
Created December 1, 2015 00:34
Unlock & Reset AD account powershell
$fool = 'aduseraccount'
$adserver = 'adservername'
Invoke-Command -ComputerName $adserver `
-ScriptBlock {param($u); Import-Module ActiveDirectory; Unlock-ADAccount -Identity $u} -ArgumentList $fool
Invoke-Command -ComputerName $adserver `
-ScriptBlock {param($u); Import-Module ActiveDirectory; Set-ADAccountPassword -Identity $u -NewPassword (convertto-securestring "Passw0rd!" -asplaintext -force) -Reset} -ArgumentList $fool
@lantrix
lantrix / hosts.ps1
Last active August 31, 2018 20:43 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell Functions for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
Function Add-Host {
<#
.SYNOPSIS
@lantrix
lantrix / gitflow-breakdown.md
Created December 10, 2015 05:12 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@lantrix
lantrix / template.json
Created December 23, 2015 04:39 — forked from sebdah/template.json
EC2 Windows - Joining a domain via cfn-init
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"<powershell>\n",
"pip install -U cumulus-bundle-handler\n",
"# Join the AD domain\n",
"$password = \"MyPassW0rd\" | ConvertTo-SecureString -asPlainText -Force\n",
"$username = \"example.com\\username\"\n",
"$credential = New-Object System.Management.Automation.PSCredential($username,$password)\n",
"Add-Computer -domainname example.com -OUPath \"OU=Servers,OU=Resources,OU=ORGANIZATION,DC=example,DC=com\" -Credential $credential -passthru \n",
@lantrix
lantrix / install-nuget.sh
Created January 13, 2016 05:13
Install nuget.exe on Mac for installing Fake.exe for F# builds
sudo mozroots --import --sync
curl -L http://nuget.org/nuget.exe -o nuget.exe
mono nuget.exe install FAKE -OutputDirectory tools -ExcludeVersion
@lantrix
lantrix / invokePS.fsx
Created January 15, 2016 05:30
Invoke Powershell in F#
#r "System.Management.Automation"; open System.Management.Automation
let push = PowerShell.Create()
push.AddScript("Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned; ..\\Scripts\\PublishToS3.ps1")
push.Invoke()
@lantrix
lantrix / Get-CertificateExpirations.ps1
Last active June 13, 2017 15:02
Powershell Check Cert Expiry Days
#requires -Version 3
<#
.SYNOPSIS
Search Servers for a certificate and show expiry date
.EXAMPLE
Get-CertificateExpirations.ps1 -Servers @("serverA.local","serverB.local") -CertName test.com.au
#>
param(
[Parameter(Mandatory=$true,HelpMessage='Certificate Name')][string]$CertName,
@lantrix
lantrix / ntptime.ps1
Created February 10, 2016 01:48
Powershell Set + Test NTP on Windows Server
#Enabled w32tm debug
w32tm /debug /enable /file:C:\w32tmdebug.log /size:10485760 /entries:0-300
#Configure NTP
Push-Location
Set-Location HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers
Set-ItemProperty . 1 "server1.domain.local"
Set-ItemProperty . 2 "server2.domain.local"
Set-ItemProperty . "(Default)" "1"
Set-Location HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Parameters