Skip to content

Instantly share code, notes, and snippets.

@dindoliboon
dindoliboon / aes_example.ps1
Last active August 12, 2020 22:43
Encrypt and decrypt with PowerShell
function Get-PlaintextFromSecureString([SecureString]$SecureString) {
return (New-Object -TypeName System.Net.NetworkCredential('fake-user', $SecureString, 'fake-domain')).Password
}
function EncryptStringToBytes([String]$Plaintext, [System.Security.SecureString]$Password) {
# C# code from:
# https://gist.github.com/mark-adams/87aa34da3a5ed48ed0c7
# https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=netframework-4.8
$Aes = $null
@dindoliboon
dindoliboon / BcxDevCmd.bat
Created March 23, 2020 02:16
Set BCX development environment
@ECHO OFF
SET BCX_ROOT=C:\Program Files (x86)\BCX
SET PATH=%PATH%;C:\Program Files (x86)\BCX\Bin;C:\Program Files\PellesC\Bin
ECHO BCXCON - Compile console applications
ECHO BCXDLL - Compile dynamic libraries
ECHO BCXGUI - Compile GUI applications
@dindoliboon
dindoliboon / Jwt-CreateToken.ps1
Last active March 6, 2024 19:47
System.IdentityModel.Tokens.Jwt with PowerShell to create JWT using RS256
<#
System.IdentityModel.Tokens.Jwt with PowerShell to create JWT using RS256.
http://blog.d-apps.com/2013/08/powershell-and-json-web-token-handler.html
Tested using:
Windows 10.0.18362.628
PowerShell 7.0.0
Windows PowerShell 5.1.18362.628
NuGet 5.4.0.6315
System.IdentityModel.Tokens.Jwt 5.6.0
@dindoliboon
dindoliboon / libMaxMindGeoIp2V1.psm1
Last active December 6, 2020 23:55
PowerShell library for performing geo IP lookups.
<#
PowerShell library for performing geo IP lookups.
Requirements:
- PowerShell 7.0.0 or Windows PowerShell 5.1.18362.628
https://github.com/PowerShell/PowerShell/releases
- nuget 5.4.0.6315
Invoke-WebRequest -Uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile (Join-Path -Path ([Environment]::GetFolderPath('UserProfile')) -ChildPath 'Downloads\nuget.exe')
@dindoliboon
dindoliboon / libGoogleAdminDirectoryV1.psm1
Created April 3, 2018 15:16
Windows PowerShell library for performing basic requests on Google Apps User resources.
<#
Windows PowerShell library for performing basic requests on Google Apps User resources.
These are general steps and may not follow the Google Dashboard step-by-step.
Requirements:
- .NET Framework 4.5
https://www.microsoft.com/net/download/dotnet-framework-runtime
- .NET Core SDK 2.1.101
@dindoliboon
dindoliboon / AadSyncStatusConsole-thumbnail.png
Last active October 26, 2021 14:56
Poll Azure AD Connect for the current sync status and initiate a delta sync cycle.
AadSyncStatusConsole-thumbnail.png
@dindoliboon
dindoliboon / shibidp-deploy.ps1
Last active April 15, 2021 22:08
Deploy basic install of Shibboleth IdP on Windows Server 2019.
#
# Moved code to shibidp-deploy.psm1.
#
# Must call function now, but this allows customization using parameters.
#
# Perform default install.
# iex (iwr 'https://gist.githubusercontent.com/dindoliboon/553884cfc67cc2672a786e4aee69cd63/raw/shibidp-deploy.ps1').Content
#
# Example on customizing non-HTTPS port and Java heap size.
# iex (iwr 'https://gist.githubusercontent.com/dindoliboon/553884cfc67cc2672a786e4aee69cd63/raw/shibidp-deploy.psm1').Content; Install-App -JettyNonHttpsPort 8081 -JavaMinimumHeapSize '4g' -JavaMaximumHeapSize '4g'
@dindoliboon
dindoliboon / Set-PropertyValue.ps1
Created June 20, 2017 14:36
Updates simple property files.
function Set-PropertyValue
{
[CmdletBinding()]
param($Path, $Key, $Value, $Separator='=', $Comment="# ", $Backup=$true)
$ini = Get-Content -Path $Path
$newIniPath = [System.IO.Path]::GetTempFileName()
$found = $false
$ini.Split("`n") |% {
@dindoliboon
dindoliboon / Get-WebFile.ps1
Last active May 13, 2019 15:18
Download files in Nano Server.
<#
.DESCRIPTION
Downloads a file from the specified website.
.EXAMPLE
Downloads Jetty 9.3.20.
Get-WebFile -Uri 'http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.3.20.v20170531/jetty-distribution-9.3.20.v20170531.zip' -OutFile 'C:\jetty-distribution-9.3.20.v20170531.zip'
.EXAMPLE
Downloads Oracle Server JRE 8u131 and verifies hash.
Get-WebFile -Uri 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/server-jre-8u131-windows-x64.tar.gz' -OutFile 'C:\server-jre-8u131-windows-x64.tar.gz' -Cookie 'oraclelicense=accept-securebackup-cookie;' -Hash '1806EBE235EAB2B21C893ACBF0B287A392CE6B5EDFEA3286FC8FF7D6DEFB19CB'
.OUTPUTS
@dindoliboon
dindoliboon / OracleFormsJnlpGenerator.ps1
Created May 6, 2016 20:53
Generates JNLP file from an Oracle Forms application to use locally or on a web server. Allows Oracle Forms application to run without a web browser.
<#
Generates JNLP file from an Oracle Forms application.
Tested against an Oracle Forms 11g server.
Information from:
Jan Carlin's Blog - Forms and Java Web Start
https://web.archive.org/web/20081201161421/http://groundside.com/blog/JanCarlin.php
#>