Skip to content

Instantly share code, notes, and snippets.

View Fabaderheld's full-sized avatar

Fabian Sasse Fabaderheld

View GitHub Profile
@Fabaderheld
Fabaderheld / Get-FilesSize.ps1
Last active June 21, 2022 04:40
Get-FilesSize.ps1
($FileSize | Measure-Object -Sum length).Sum / 1GB

Set-PSReadLineOption -EditMode Emacs -PredictionSource history -PredictionViewStyle ListView

oh-my-posh init pwsh --config C:\Users\Fabia\AppData\Local\Programs\oh-my-posh\themes\craver.omp.json | Invoke-Expression

@Fabaderheld
Fabaderheld / Set-AzAPIPermission.ps1
Last active July 7, 2022 18:32
Permissions Ids for Graph
Get Permissions
# MS Graph Permissions
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).AppRole | Select *
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).Oauth2PermissionScope | Select *
# Azure AD Graph
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).AppRole | Select *
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).Oauth2PermissionScope | Select *
@Fabaderheld
Fabaderheld / gist:77fd15969302c65f35c407cdf6368113
Created July 19, 2022 05:03
Generate .m3u frrom .cue files
Get-ChildItem | ForEach-Object { (Get-ChildItem $_.Fullname -Recurse | Where-Object { $_.Name -like "*.cue" } | Select-Object name).Name | Out-File "$($_.FullName)\$($_.Name).m3u" }
@Fabaderheld
Fabaderheld / Create Terraform storagebackend.md
Created September 6, 2022 04:50
Create Terraform storagebackend

Connect-AzAccount

Create Azure Service Princal

$sp = New-AzADServicePrincipal -DisplayName "terraform" -Role "Contributor" $sp.AppId $sp.PasswordCredentials.SecretText

Create Terraform storage backend

@Fabaderheld
Fabaderheld / Sprit.md
Last active September 19, 2022 07:01

$GasStations = (Invoke-WebRequest -Uri "https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48.2505077&longitude=16.4019153&fuelType=SUP&includeClosed=false" -ContentType application/json).Content | ConvertFrom-Json | Where-Object { $_.Prices -ne $null } | Select-Object Name, Location, distance, prices

foreach ($GasStation in $GasStations) { [PSCustomObject]@{ Name = $GasStation.Name Location = $GasStation.Location.address "Distance(km)" = [System.Math]::Round($GasStation.Distance, 2) Price = $GasStation.prices.amount } }

@Fabaderheld
Fabaderheld / Work with Word
Last active June 13, 2023 08:11
Work with Word documents in Powershell
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Word.dll" # Load Word Interop assembly
$Word = New-Object -ComObject Word.Application # Create new Word object
# Get Active Document
$doc = $word.ActiveDocument # Get active document
# Add Logo
$logoPath = "C:\temp\stv\stv-04.png" # Path to logo
$logoShape = $doc.Shapes.AddPicture($logoPath, $false, $true).ConvertToInlineShape() # Add logo
$logoShape.LockAspectRatio = $true # Lock aspect ratio
function Click-Button1 {
# Specify the path to your logo image file
$logoPath = "C:\temp\stv\stv-04.png"
# Get the current Word document
$doc = $app.ActiveDocument
# Add the logo to the document
$logoShape = $doc.Shapes.AddPicture($logoPath, @{LinkToFile = $false; SaveWithDocument = $true }).ConvertToInlineShape()
@Fabaderheld
Fabaderheld / comicinfo.md
Last active July 30, 2023 04:36
Open Metadata from an CBZ file in Powershell

function Get-ComicInfo { [CmdletBinding()] param ( [Parameter()] [String] [Alias("Name", "ComicFile")] $Path )

If the path starts with "./", replace it with the current working directory ($PWD)