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 / 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 / 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 / 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 / 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 / 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() }