Skip to content

Instantly share code, notes, and snippets.

View zakes-it's full-sized avatar

Michael Le-Zakes zakes-it

View GitHub Profile
@zakes-it
zakes-it / userContent.css
Created July 23, 2019 23:40
Custom Firefox css to hide channel sidebar and message entry to maximize message space on kiosk/monitoring displays
@-moz-document domain(app.slack.com) {
.p-workspace__sidebar { display: none !important; }
.p-workspace__primary_view { grid-column-start: p-workspace__sidebar !important; }
.p-workspace__primary_view_footer { display: none !important; }
}
@zakes-it
zakes-it / munkiADConditions
Created July 23, 2019 22:28
provides Active Directory binding and group conditions data for Munki
#!/usr/bin/python
"""
Provides Munki with the following custom conditions related to Active Directory:
adBound: boolean for if the computer is bound to AD
adDomain: the fully qualified Active Directory Domain name or an empty
string if not bound
adConnected: boolean for if the computer can communicate with the domain
adUserGroups: a list of AD security groups the currently logged in user is a
member of. List will be empty if the computer is not bound or no user is
logged in.
@zakes-it
zakes-it / get_platform.py
Created July 23, 2019 21:10
get macOS serial and model information
#! /usr/bin/python
from OpenDirectory import ODNode, ODSession, kODRecordTypeUsers, \
kODRecordTypeGroups, kODRecordTypeComputers
from SystemConfiguration import SCDynamicStoreCreate, SCDynamicStoreCopyValue
class ActiveDirectory(object):
def __init__(self, creds):
self.creds = creds
self.info = self.get_bind_info()
@zakes-it
zakes-it / activedirectory.py
Created July 23, 2019 21:07
Python class for macOS client asset management in AD: get AD bind info, user/group info and set computer description
#! /usr/bin/python
from OpenDirectory import ODNode, ODSession, kODRecordTypeUsers, \
kODRecordTypeGroups, kODRecordTypeComputers
from SystemConfiguration import SCDynamicStoreCreate, SCDynamicStoreCopyValue
class ActiveDirectory(object):
def __init__(self, creds):
self.creds = creds
self.info = self.get_bind_info()
@zakes-it
zakes-it / d42lib.py
Last active July 23, 2019 21:00
Python class for managing client system asset tracking with Device 42
import getpass
import requests
import datetime
from requests.packages.urllib3.exceptions import SubjectAltNameWarning
requests.packages.urllib3.disable_warnings(SubjectAltNameWarning)
class D42Server(object):
def __init__(self, url, username, password=None):
@zakes-it
zakes-it / AirportKiller.py
Last active May 18, 2020 15:32
Use with crankd turn off AirPort when on an Ethernet connection and turn AirPort back on when Ethernet disconnects
#! /usr/bin/python
import syslog
import objc
from Foundation import NSAppleScript, CFPreferencesCopyAppValue,\
CFPreferencesSetAppValue, CFPreferencesAppSynchronize
from SystemConfiguration import SCDynamicStoreCreate, SCDynamicStoreCopyValue
BUNDLE_ID = 'AirportKiller'
@zakes-it
zakes-it / Terminate-ADAccount.ps1
Created August 4, 2016 23:08
Disable an Active Directory account, logging the group membership, stripping group membership and moving the account to a disabled users OU
# turn down the AD account
Function Terminate-ADAccount {
[CmdletBinding()]
Param(
[System.Object[]]$user,
[System.Management.Automation.PSCredential]$cred,
[String]$DisabledOu,
[String]$MembershipLogPath
)
# Retrieve groups that the user is a member of
@zakes-it
zakes-it / Set-ConfluencePerms.ps1
Created August 4, 2016 22:59
Set confluence permissions for a user account
Function Set-ConfluencePerms {
[CmdletBinding()]
param(
[string]$user,
[array]$groups,
[string]$URL,
$cred
)
# login to confluence
$u = $URL
@zakes-it
zakes-it / Disable-SlackAccount.ps1
Created August 4, 2016 22:52
Disable Slack account matching a username
Function Disable-SlackAccount {
[CmdletBinding()]
Param(
[String]$user,
[String]$org,
[String]$token
)
$SlackUsers = Invoke-RestMethod -Uri $( "https://" +$org + ".slack.com/api/users.list?token=" + $token )
if ( ! $SlackUsers.ok ) {
Write-Error ( "Error getting user list from Slack: " + $SlackUsers.error )
@zakes-it
zakes-it / Remove-TrelloUser.ps1
Created August 4, 2016 22:43
Deactivate a Trello account matching an Active Directory user
# Get-oAuth2AccessToken and Get-TrelloToken functions copied from
# https://github.com/danroot/PowerTrello
Function Remove-TrelloUser {
[CmdletBinding()]
Param(
# Active Directory user hash
[Parameter(Mandatory = $true)] $user,
# Get your key by signing in Trello and visit https://trello.com/app-key
[Parameter(Mandatory = $true)] [string] $appKey,