Skip to content

Instantly share code, notes, and snippets.

View scottd3v's full-sized avatar
🎯
Focusing

Scott Reed scottd3v

🎯
Focusing
View GitHub Profile
@scottd3v
scottd3v / eventsPwsh.ps1
Created October 19, 2018 16:31
Events API PowerShell Example
$JCAPIKey = '' # Enter API Key here
$StartDate = (Get-Date(Get-Date).AddDays(-1) -Format s)
$EndDate = (Get-Date -Format s)
$hdrs = @{"X-API-KEY" = "$JCAPIKey"}
$EventsAPI = "https://events.jumpcloud.com/events?startDate=$StartDate`Z&endDate=$EndDate`Z"
$events = Invoke-RestMethod -Method GET -Uri $EventsAPI -Header $hdrs
# To output to a file run the below command
$events | ConvertTo-Json | Out-File EventsData.txt
$UserGroups = @(
"All Users",
"Default Admin",
"Developers",
"Sales",
"Accounting"
)
$UserGroups | % { New-JCUserGroup -GroupName $_}
#!/bin/bash
# Ensures that script is run as ROOT
if [[ "${UID}" != 0 ]]; then
(echo >&2 "Error: $0 script must be run as root")
exit 1
fi
# Ensures that the system is not domain bound
readonly domainBoundCheck=$(dsconfigad -show)
if [[ "${domainBoundCheck}" ]]; then
#!/bin/bash
: '
Script to rename the username of a user account on MacOS
The script updates the users record name (username), RealName (displayName), and home directory
If the user receiving the name change is signed in they will be signed out.
Example usage: sudo sh RenameMacUserNameAndHomeDirectory.sh cat dog
@scottd3v
scottd3v / PowerShell calculated properties.ps1
Last active April 6, 2018 19:00
Changing the output of Get-JCUserGroupMember
#Change 'Students' to the JumpCloud User Group you want to query
#Outputs the membership in 'FirstName LastName' syntax instead of the 'Username'
#An API call is done for each group member so this may take some time depenindg on the size of the group
#Tested on PowerShell core version 6.0.1
Get-JCUserGroupMember -GroupName 'Students' | Select-Object GroupName, @{name = 'FullName'; Expression = {(Get-JCUser -Username $_.Username | Select-Object @{Name ='FullName'; Expression = {"$($_.Firstname) $($_.LastName)"}})}} | Select-Object GroupName, @{Name = 'FullName'; Expression={ ($_.FullName.FullName)}}