Skip to content

Instantly share code, notes, and snippets.

View ntrogers's full-sized avatar

ntrogers ntrogers

View GitHub Profile
@ntrogers
ntrogers / python_recursive_filesearch.py
Last active January 4, 2018 18:49
[Python - Recursive Search] Recursive file search #python #snippet
# Recursivly search for a specific file in all users home folders
import glob
for f in glob.iglob('/Users/*/Library/Preferences/com.apple.spaces.plist'):
print f
@ntrogers
ntrogers / create_AD_user.ps1
Last active September 8, 2017 15:37
[AD - Create/Edit AD User] Create/edit AD user via powershell, password in plain text #Windows #Powershell #ActiveDirectory
New-ADUser -SamAccountName <userName> -GivenName <firstName> -SurName <lastName> -Name "<firstName> <lastName>" -DisplayName "<firstName> <lastName>" -UserPrincipalName <userName>@<domain> -ChangePasswordAtLogon $true -AccountPassword (ConvertTo-SecureString <password> -AsPlainText -force) -Enabled $True -PasswordNeverExpires $False -PassThru -Path "OU=<ou>,OU=<path>,DC=<domain>,DC=<path"
@ntrogers
ntrogers / list_AD_OUs.ps1
Last active September 8, 2017 15:37
[AD - List AD OUs] List all AD OUs in a domain #Windows #Powershell #ActiveDirectory
Get-ADOrganizationalUnit -filter * -SearchBase "DC=<domain>,dc=<path>”  | ft distinguishedname
@ntrogers
ntrogers / macOS_unbind_from_od.sh
Last active September 11, 2017 21:47
[macOS - Unbind OD] Unbind a macOS client from an OD server #macOS
dsconfigldap -r <ServerAddress>
@ntrogers
ntrogers / macOS_OD_list.sh
Last active September 11, 2017 21:46
[macOS - List OD binding] List currently bound OD servers #macOS
dscl localhost -list /LDAPv3
@ntrogers
ntrogers / macOS_setup_NTP.sh
Last active September 11, 2017 21:46
[macOS - Set NTP] Enable NTP and set server/timezone #macOS
systemsetup -setnetworktimeserver time.apple.com
systemsetup -setusingnetworktime on
systemsetup -settimezone America/Anchorage
@ntrogers
ntrogers / macOS_software_version.sh
Last active September 11, 2017 21:46
[macOS - Software Version] Display macOS software version #macOS
system_profiler SPSoftwareDataType | grep "System Version"
@ntrogers
ntrogers / macOs_current_user.sh
Last active September 11, 2017 21:46
[sh - Get Current user] Get currently logged in user #macOS #Bash
stat -f%Su /dev/console
@ntrogers
ntrogers / sh_get_client_ip.sh
Last active September 11, 2017 21:34
[sh - Get Client IP] Get Client IP Address #macOS #nix #Bash
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
@ntrogers
ntrogers / macOS_get_client_hostname.sh
Last active September 11, 2017 21:45
[macOS - Get Client Hostname] Get Hostname of Client #macOS
scutil --get ComputerName