Skip to content

Instantly share code, notes, and snippets.

AWK • SED • GREP: Together we can change anything!

Download a PDF of my slides and notes

awk sed grep circle logo

Example code from my MacAdmins Conference at Penn State 2024 presentation.

Battery cycle count

@talkingmoose
talkingmoose / iOS and iPadOS 18 and watchOS 11 compatible devices (regex)
Last active September 6, 2024 10:09
Regex looks for all iPhone and iPad models compatible with iOS or iPadOS 18 and Apple Watch models compabiel with watchOS 11. May not be up-to-date with newly released models.
https://www.apple.com/ios/ios-18-preview/
https://www.apple.com/ipados/ipados-18-preview/
https://www.apple.com/watchos/watchos-preview/
Published Date: June 10, 2024
Updated June 19, 2024
Verification: https://regex101.com/r/0UDJHk/6
@talkingmoose
talkingmoose / Download and Install Mozilla Firefox.zsh
Last active August 27, 2024 18:39
Downloads and installs the latest available Mozilla Firefox for Mac software directly on the client. This avoids having to manually download and store an up-to-date installer on a distribution server. Includes an optional checksum for added security.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/b99a43948c4784631e9ad60eb714c776
@talkingmoose
talkingmoose / Download and Install VLC.zsh
Last active August 27, 2024 18:19
Downloads and installs the latest available VLC software directly on the client. This avoids having to manually download and store an up-to-date installer on a distribution server. Includes an optional checksum for added security.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/84cbe002aca35c73032bccd230d8988a
@talkingmoose
talkingmoose / Back up Jamf Pro objects.zsh
Last active August 26, 2024 03:53
Download JSON or XML files for multiple Jamf Pro object types.
#!/bin/zsh
# set -x # show command
:<<ABOUT_THIS_SCRIPT
Written by:William Smith
Technical Enablement Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/4a950a715ad07ae3baecce2f46b0a7e5
@talkingmoose
talkingmoose / Re-enroll computers for LAPS.zsh
Last active August 21, 2024 12:55
Use a Jamf Pro policy to re-enroll a computer to install a LAPS management account, and then create a launch daemon and script to update inventory immediately.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Technical Enablement Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/9f4638932df28c4bebde5dd47be1812a
@talkingmoose
talkingmoose / Match Version Number or Higher.bash
Last active August 8, 2024 15:22
Generates a regular expression (regex) that matches the provided version number or higher. Useful for Jamf Pro's "matches regex" operator in searches and smart groups where the results need to be the current version of an app or higher.
#!/bin/bash
<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/2cf20236e665fcd7ec41311d50c89c0e
@talkingmoose
talkingmoose / Set Computer PreStage Scope.bash
Last active July 18, 2024 13:00
As of Jamf Pro 10.14, the Jamf Pro API (/uapi) allows access to create and update scopes for computer PreStage Enrollments. Edit the information at the top and include a list of computer serial numbers for the COMPLETE scope. (The script replaces the scope list; it doesn't update.) Be sure to leave the opening and closing parentheses.
#!/bin/bash
# server connection information
URL="https://talkingmoose.jamfcloud.com"
username="API-Editor"
password="P@55w0rd"
# provide the Jamf Pro ID of the PreStage Enrollment; look in the URL when viewing the PreStage Enrollment
prestageID="1"
@talkingmoose
talkingmoose / Sequoia-compatible Macs (regex)
Last active June 28, 2024 16:54
Regex looks for all Mac models compatible with macOS Sequoia. May not be up-to-date with newly released models.
https://www.apple.com/macos/macos-sequoia-preview/
Published Date: June 10, 2024
Updated June 28, 2024
Verification: https://regex101.com/r/bNOMXz/4
1) Exact regex — Matches major model identifier numbers based on Apple's knowledge base article (more accurate):
^(Mac(1[345]|BookPro1[5-8]|BookAir(9|10)|Pro7)|iMac(Pro1|(19|2[01]))|Macmini[89]),\d+$
@talkingmoose
talkingmoose / Download and Install Microsoft product.zsh
Last active June 26, 2024 16:52
Downloads and installs the latest available Microsoft product specified directly on the client. This avoids having to manually download and store an up-to-date installer on a distribution server every month.
#!/bin/zsh
:<<'ABOUT_THIS_SCRIPT'
-----------------------------------------------------------------------
Written by:William Smith
Partner Program Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/b6637160b65b751824943ede022daa17