Skip to content

Instantly share code, notes, and snippets.

View FriedrichWeinmann's full-sized avatar

Friedrich Weinmann FriedrichWeinmann

View GitHub Profile
@FriedrichWeinmann
FriedrichWeinmann / Invoke-SystemCommand.ps1
Created January 24, 2023 16:54
Execute a scriptblock as SYSTEM by setting up a temporary scheduled task.
function Invoke-SystemCommand {
<#
.SYNOPSIS
Execute a scriptblock as SYSTEM by setting up a temporary scheduled task.
.DESCRIPTION
Execute a scriptblock as SYSTEM by setting up a temporary scheduled task.
.PARAMETER Name
The name of the task
@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 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
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));
}
@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 Get-GpoBackupName {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('FullName')]
[string]
$Path
)
process {
foreach ($folder in $Path) {
@FriedrichWeinmann
FriedrichWeinmann / DomainCryptographyScan.ps1
Last active May 30, 2023 05:15
Scans an Active Directory domain's and its principal's kerberos encryption configuration.
<#
.SYNOPSIS
Scans an Active Directory domain's and its principal's kerberos encryption configuration.
.DESCRIPTION
Scans an Active Directory domain's and its principal's kerberos encryption configuration.
It will generate all data via LDAP, and analyze the results for possible authentication issues.
It supports three ways to report:
- Print: Write analysis of results to screen
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