Skip to content

Instantly share code, notes, and snippets.

@jbaker10
jbaker10 / gsuite_to_ad_sync.py
Created October 14, 2019 14:09
Code to help sync user 's from G Suite to Active Directory
# MIT License
# Copyright (c) 2019 Jeremy Baker
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#!/usr/bin/python
import os, subprocess, plistlib, re, sys
from os import listdir
from subprocess import PIPE
def isRoot():
if not os.geteuid() == 0:
print "\nRunning as standard account."
print "Re-launching script with sudo rights..."
import os
import csv
import json
import requests
from requests.auth import HTTPBasicAuth
user_emails = []
with open("/Users/jeremy.baker/Desktop/Members_03jtnz0s2flbciv_04122019_184656.csv", "r") as f:
csv_reader = csv.reader(f, delimiter=',')
import yaml
from itertools import islice
user = {
"email": "jeremy.baker@domain.com",
"department": "Sales",
"title": "Senior Account Executive",
"location": "New York",
"salesRegion": "Americas",
"costCenter": "Enterprise Sales",
@jbaker10
jbaker10 / show_prompt.ps1
Created August 26, 2019 21:46
Show prompt in Windows 10
Add-Type -AssemblyName PresentationCore,PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::YesNo
$MessageboxTitle = “AppGate Upgrade Notice”
$Messageboxbody = “Corp IT needs to upgrade the AppGate client on your device. This upgrade will quit any running sessions of AppGate and may take a few minutes to complete. Are you ready to proceed?”
$MessageIcon = [System.Windows.MessageBoxImage]::Warning
$decision = [System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$messageicon)
$decision
import json
import time
from httplib2 import Http
from apiclient import discovery, errors
from datadog import initialize, api
from datetime import datetime
from oauth2client.service_account import ServiceAccountCredentials
########
## Edit the variables below as necessary
$url = "http://zoom.us/client/latest/ZoomInstallerFull.msi"
$output = "C:\Temp\Zoom.msi"
########
try {
## Kill the process if running
"Trying to quit the application if running"
Stop-Process -Name Zoom* -Force
@jbaker10
jbaker10 / enroll_in_airwatch.ps1
Created December 10, 2018 18:28
enroll_in_airwatch.ps1
$url = "https://storage.googleapis.com/getwsone-com-prod/downloads/AirwatchAgent.msi"
$output = "C:\Temp\AirWatchAgent.msi"
"Checking if temp dir exists, creating if not"
$path = "C:\Temp"
if(!(Test-Path -Path $path)){
"Creating temp directory"
New-Item -ItemType directory -Path $path
}
"Getting currently logged in user"
$user = '{0}\{1}' -f $env:USERDOMAIN, $env:USERNAME
"Working with user account: " + $user
$user_members = Get-LocalGroupMember -Group Administrators
if ($user_members.Name -like $user) {
$user + " is already a member of the Administrators group"
}
$path = "C:\Temp"
if(!(Test-Path -Path $path)){
"Creating C:\Temp"
New-Item -ItemType directory -Path $path
}
$url = "http://slack.com/ssb/download-win64-msi"
$output = "C:\Temp\slack.msi"