Skip to content

Instantly share code, notes, and snippets.

View phatmandrake's full-sized avatar
😄
Happy

phatmandrake

😄
Happy
View GitHub Profile
@phatmandrake
phatmandrake / dscofigad.sh
Created October 10, 2023 15:03
JAMF MacOS dsconfigad Expect workaround
#!/bin/zsh
:'
There is an apparent bug in dsconfigad for MacOS that will cause dsconfigad to arbitrarily
fail to bind to an existing computer record silently, even with the use of a force flag.
When this happens, disconfigad prompts for approval interactively. This causes JAMF to over
log the output to a tmp file that will eat all available harddisk space. This is particularly
problematic in environments using self-healing AD binding scripts. By introducing expect,
we can ensure that the y/n prompt is responded to or in the event of signficant network delay,
terminated after 60 seconds. This gist can be used as a template for how to use expect, but follow best
@phatmandrake
phatmandrake / Hashtable.ps1
Created April 5, 2023 14:16
Conditional Variable Assigments in a Hashtable cast to PSCustomObject
Get-Process -pv p | ForEach-Object {
[PSCustomObject]@{
Name = $p.name
ProcessHasDescription = $(if ($p.description) { $True }else { $False })
Description = $(if ($p.description) { $p.Description } else { $null })
}
}
@phatmandrake
phatmandrake / $Host.EnterNestedPrompt() - End Block Behavior.ps1
Created February 3, 2023 17:05
$Host.EnterNestedPrompt() - End Block Behavior
function f {
[Cmdletbinding()]
param([switch]$intervene)
begin{
$abc = 123
}
process{
}
end{
@phatmandrake
phatmandrake / key.md
Created February 3, 2023 03:33
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

@phatmandrake
phatmandrake / PSCustomObject to Hashtable.ps1
Last active March 16, 2022 22:16
Convert a PSCustomObject to a Dictionary/Hashtable
class PSHashTable : Collections.Generic.Dictionary[string, string]{
PSHashTable ([PSCustomObject]$Object) {
$Object.psobject.properties | ForEach-Object -Process {$this.add($_.name,$Object.($_.name))}
}
}
[HashTable][PSHashTable][PSCustomObject]@{Prop = "val"}
@phatmandrake
phatmandrake / Get-MacOSCodeSign.ps1
Last active August 3, 2021 20:07
Get the BundleID and CodeSignRequirement from an app bundle by specifying the path. You can then create PPPC profiles directly in JAMF.
function Get-MacOSCodeSign {
param (
[parameter(Mandatory)]
[String]$AppPath
)
process {
$CodesignBundleID = (ConvertFrom-StringData -StringData $(codesign -dv $AppPath 2>&1 | Out-String)).identifier
$CodesignRequirement = (($(codesign -dr - $AppPath 2>&1) | Out-String) | Select-String "(?<=designated \=> ).*").matches.value