Skip to content

Instantly share code, notes, and snippets.

View tabs-not-spaces's full-sized avatar
💀
Always working from home

Ben R. tabs-not-spaces

💀
Always working from home
View GitHub Profile
@tabs-not-spaces
tabs-not-spaces / Reset-SidecarScript.ps1
Last active May 28, 2020 10:08
Intune authentication example
if (!(Get-Module -Name MSAL.PS -ListAvailable -ErrorAction SilentlyContinue)) {
Install-Module -Name MSAL.PS -Scope CurrentUser -Force
}
$clientId = "d1ddf0e4-d672-4dae-b554-9d5bdfd93547" # well known Intune application Id
$auth = Get-MsalToken -ClientId $clientId -deviceCode #deviceCode requires interaction and solves MFA challenges
$token = @{ Authorization = $auth.CreateAuthorizationHeader() }
@tabs-not-spaces
tabs-not-spaces / Get-TenantIdFromDomain.ps1
Created September 4, 2018 06:17
Get-TenantIdFromDomain
function Get-TenantIdFromDomain {
param (
[Parameter(Mandatory = $true)]
[string]$FQDN
)
try {
$uri = "https://login.microsoftonline.com/$($FQDN)/.well-known/openid-configuration"
$rest = Invoke-RestMethod -Method Get -UseBasicParsing -Uri $uri
if ($rest.authorization_endpoint) {
$result = $(($rest.authorization_endpoint | Select-String '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}').Matches.Value)
@tabs-not-spaces
tabs-not-spaces / logon script
Created January 29, 2019 06:58
logon script
<#
.SYNOPSIS
Logon script for the EUC Environment.
.DESCRIPTION
Configures the following things:
- Map Network Drives if the UNC path is connectable (must be onPrem)
.NOTES
Author: Ben Reader
Company:
@tabs-not-spaces
tabs-not-spaces / chrome-install.ps1
Created March 15, 2019 07:27
Install the latest version of chrome - every time. without fail.
try {
Write-Host "downloading installer.."
$chromeUri = "https://dl.google.com/chrome/install/latest/chrome_installer.exe"
$bitsJob = Start-BitsTransfer -Source $chromeUri -Destination "$env:Temp\$(split-path $chromeUri -leaf)"
if (Test-Path -Path "$env:Tempchrome_installer.exe") {
Write-Host "Installer downloaded successfully..`nInstalling application"
$proc = Start-Process -FilePath "$env:Tempchrome_installer.exe" -ArgumentList "/silent /install" -Wait
$fileDetectPath = "${env:ProgramFiles(x86)}\Google\Chrome\Application\Chrome.exe"
Write-Host "Looking for installation files: $fileDetectPath.."
if (Test-Path -Path "$fileDetectPath") {
@tabs-not-spaces
tabs-not-spaces / Connect-iDrac.ps1
Created March 21, 2019 00:08
Connect to iDrac console from PowerShell
function Connect-iDrac {
[CmdletBinding()]
param (
[IPAddress]$dracHost,
$dracUser
)
try {
$cred = Get-Credential -UserName $dracUser -Message "Please enter iDrac credentials.." -Title "Connect-iDrac"
$jrePath = "C:\bin\jre1.7.0_80" #set to your jre binaries root folder.
$kvmJar = "$jrePath\avctKVM.jar"
@tabs-not-spaces
tabs-not-spaces / cloudSettings
Last active September 23, 2020 13:04
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-23T13:04:03.524Z","extensionVersion":"v3.4.3"}
@tabs-not-spaces
tabs-not-spaces / ConvertFrom-Base64EncodedString.ps1
Last active December 9, 2019 23:19
very simple decoder for scripts in graph
function ConvertFrom-Base64EncodedString {
[cmdletbinding()]
param (
[string]$encodedString
)
try {
$decodedOutput = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($encodedString))
return $decodedOutput
}
catch {
@tabs-not-spaces
tabs-not-spaces / monokai-pro-colourscheme.json
Last active November 24, 2020 12:19
monkai colour theme for Microsoft Terminal!
// Place this at the bottom of the "schemes" array in your profiles.json for the win.
{
"background": "#2d2a2e",
"black": "#2d2a2e",
"blue": "#FC9867",
"brightBlack": "#727072",
"brightBlue": "#FC9867",
"brightCyan": "#78DCE8",
"brightGreen": "#a9dc76",
"brightPurple": "#AB9DF2",
$script:tick = [char]0x221a
$hashPath = "$env:SystemDrive\hwhash.csv"
function Install-PreReq {
[cmdletbinding()]
param (
[Parameter(Mandatory = $true)]
[string[]]$reqs,
[Parameter(Mandatory = $false)]
[ValidateSet('Module', 'Script')]
A few handy detection functions that I use every day