Skip to content

Instantly share code, notes, and snippets.

View FriedrichWeinmann's full-sized avatar

Friedrich Weinmann FriedrichWeinmann

View GitHub Profile
@FriedrichWeinmann
FriedrichWeinmann / rollit.ps1
Created January 3, 2024 21:51
Integrate dice rolling into your commandline
function Invoke-Dice {
[Alias('roll')]
[CmdletBinding()]
param (
[int]
$Size = 20,
[int]
$Count = 1
)
@FriedrichWeinmann
FriedrichWeinmann / Import-ADPrincipalSID.ps1
Created November 7, 2023 16:22
Copies the SID from a principal in one domain into the SID history of a principal in another.
function Import-ADPrincipalSID {
<#
.SYNOPSIS
Copies the SID from a principal in one domain into the SID history of a principal in another.
.DESCRIPTION
Copies the SID from a principal in one domain into the SID history of a principal in another.
In order for this to work, some prerequisites must be met:
function Get-ADgMSAKdsKey {
<#
.SYNOPSIS
Retrieves KDS Information for a gMSA.
.DESCRIPTION
Retrieves KDS Information for a group managed service account (gMSA).
It will attempt to verify the existence of the KDS Key, but depending on the rights involed, access might be denied.
.PARAMETER ServiceAccount
@FriedrichWeinmann
FriedrichWeinmann / excel-worksheet-to-json.ts
Created September 5, 2023 08:41
Office Script - Converts a worksheet into a json format with nested properties
function main(workbook: ExcelScript.Workbook) {
// Get the active worksheet and used range.
let selectedSheet = workbook.getActiveWorksheet();
let range = selectedSheet.getUsedRange();
let texts = range.getTexts();
let returnObjects: unknown[] = [];
returnObjects = returnObjectFromValues(texts)
console.log(JSON.stringify(returnObjects));
}
function Add-PrivateKeyRights {
<#
.SYNOPSIS
Adds rights to the private key of a certificate.
.DESCRIPTION
Adds rights to the private key of a certificate.
Useful for automating service account access to a system certificate.
.PARAMETER Thumbprint
@FriedrichWeinmann
FriedrichWeinmann / RemoveOneDriveSharing.ps1
Created July 18, 2023 15:23
Removes all sharing permissions set to a user's OneDrive via graph API
#Requires -Modules MiniGraph
<#
.SYNOPSIS
Clear all sharing permissions on a user's OneDrive
.DESCRIPTION
Before running this script, use any of the suitable Connect-* Commands in the MiniGraph module to connect.
Scopes needed for this script:
- User.Read.All : To retrieve the user data from graph
function Resolve-PathEx {
<#
.SYNOPSIS
Resolve a path.
.DESCRIPTION
Resolve a path.
Allows specifying success criteria, as well as selecting files or folders only.
.PARAMETER Path
$Name = 'cmd'
$ArgumentList = @(
)
#region Functions
function Start-RedirectedProcess {
[OutputType([System.Diagnostics.Process])]
[CmdletBinding()]
param (
function Read-Hashtable {
<#
.Synopsis
Reads a hash table and returns its contents as key/value objects.
.DESCRIPTION
Reads a hash table and returns its contents as a hierarchical structure.
Use the AsHashtable switch to return the result as a flat hashtable, rather than one object per.
.PARAMETER Hashtable
@FriedrichWeinmann
FriedrichWeinmann / speakerconfig.ps1
Created March 1, 2023 11:21
Tools to update speaker settings on windows
#
function Disable-Privilege {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateSet('SeAssignPrimaryTokenPrivilege','SeAuditPrivilege','SeBackupPrivilege','SeChangeNotifyPrivilege','SeCreateGlobalPrivilege','SeCreatePagefilePrivilege','SeCreatePermanentPrivilege','SeCreateSymbolicLinkPrivilege','SeCreateTokenPrivilege','SeDebugPrivilege','SeDelegateSessionUserImpersonatePrivilege','SeEnableDelegationPrivilege','SeImpersonatePrivilege','SeIncreaseBasePriorityPrivilege','SeIncreaseQuotaPrivilege','SeIncreaseWorkingSetPrivilege','SeLoadDriverPrivilege','SeLockMemoryPrivilege','SeMachineAccountPrivilege','SeManageVolumePrivilege','SeProfileSingleProcessPrivilege','SeRelabelPrivilege','SeRemoteShutdownPrivilege','SeRestorePrivilege','SeSecurityPrivilege','SeShutdownPrivilege','SeSyncAgentPrivilege','SeSystemEnvironmentPrivilege','SeSystemProfilePrivilege','SeSystemtimePrivilege','SeTakeOwnershipPrivilege','SeTcbPrivilege','SeTimeZonePrivilege','SeTrustedCredManAccessPrivilege','SeUndockPrivi