Skip to content

Instantly share code, notes, and snippets.

View davidelambert's full-sized avatar

David E. Lambert davidelambert

  • Greensboro, NC
View GitHub Profile
@davidelambert
davidelambert / sharepoint-upload-nonworking-example.ps1
Created May 2, 2024 20:03
Upload file to SharePoint using MS Graph API
# App has only Sites.Selected **Application** permission
$AppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$LibraryUrl = "https://XXXXXXXXX.sharepoint.com/sites/YYYYYYYY/Shared%20Documents"
# NOTE: $SiteId was manually scraped from Graph Explorer
$SiteId = "XXXXXXXXX.sharepoint.com,yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy,zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"
$LocalFile = "C:\path\to\local\file\test.csv"
# Get Token using client secret flow
$Scope = "https://graph.microsoft.com/.default"
$TokenBody = @{
@davidelambert
davidelambert / Set-SystemEnvironmentVariable.ps1
Created April 29, 2024 17:59
PowerShell: Set Windows environment variable with system-wide ('Machine') scope
# Run in elevated PowerShell session
[Environment]::SetEnvironmentVariable('VariableName', 'Value', 'Machine')
@davidelambert
davidelambert / cheatsheet.yml
Created August 28, 2023 14:06 — forked from xputerax/cheatsheet.yml
YAML cheat sheet
# YAML cheat sheet
# Reference: https://www.youtube.com/watch?v=cdLNKUoMc6c
# object
person:
# string value. single/double quotes
# anchoring
name: &name "daniel" # anchor name doesn't have to be the same as key name
occupation: 'student'
@davidelambert
davidelambert / .zshrc
Created February 28, 2022 18:15
2-line zsh prompt w/ git branch
# 2-LINE PROMPT, WITH GIT BRANCH, eg:
# user@hostname ~/working/dir (git_branch)
# %
export PROMPT="%n@%m %~ "$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')$'\n'"%# "