Skip to content

Instantly share code, notes, and snippets.

@newyear2006
newyear2006 / ConvertFrom-YtTransscript.PS1
Last active April 17, 2023 13:14
Überträgt Youtube-Video-Transkripte in Objekte zur weiteren Verarbeitung
Function ConvertFrom-YtTranscript {
[CmdletBinding()]
Param(
#[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Parameter(ValueFromPipeline)]
$Transcript,
[switch]
[bool]$PreserveTime
)
@newyear2006
newyear2006 / ConsoleCursorOnOff.PS1
Last active October 29, 2020 13:11
Um den Konsolen Cursor in Windows mittels Powershell ein- und ausschalten zu können
$MethodDefinitions = @'
using System;
using System.Runtime.InteropServices;
public class ConsoleCursor {
[StructLayout(LayoutKind.Sequential)]
internal struct CONSOLE_CURSOR_INFO
{
internal uint Size;
@newyear2006
newyear2006 / Confirm-SecureBootUEFI.PS1
Created September 22, 2018 16:25
Versuch Confirm-SecurebootUEFI in Powershell nachzubauen und UEFI-Firmware-Variablen auszulesen
# peeked from C:\WINDOWS\Microsoft.Net\assembly\GAC_64\Microsoft.SecureBoot.Commands\v4.0_10.0.0.0__31bf3856ad364e35\Microsoft.SecureBoot.Commands.dll
$UEFIInterop = Add-Type @"
using System;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace UEFIInterop
{
@newyear2006
newyear2006 / Confirm-SecureBootUEFI.cs
Created September 22, 2018 16:23
Versuch Confirm-SecureBoot nachzubauen
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace UEFIFirmwareVariablenAbfragen
{
class Program
@newyear2006
newyear2006 / ConvertDeviceName.PS1
Created August 25, 2018 20:14
Konvertiert Linux-SCSI Devicenamen wie /dev/sda nach Windows PhysicalDrive0 Namen und zurück
# Konvertiert Linux-SCSI Devicenamen nach Windows PhysicalDrive Namen und zurück
Function Convert-LinuxDeviceAndWinPhysicalDrive {
Param(
[string]$deviceOrDisk
)
If ($deviceOrDisk.ToLower().IndexOf("physicaldisk") -eq 0) {
$number = [int]$deviceOrDisk.Substring(12)
If ($number -gt 25) {
Write-Error ">25 unsupported!"
@newyear2006
newyear2006 / WindowsRuntimeAPIFeaturesDetection.PS1
Created March 5, 2018 20:39
UWP ApiFeatures per Powershell abfragen
# zunächst brauchen wir eine Windows Runtime Referenz
Add-Type -AssemblyName System.Runtime.WindowsRuntime
# dann die passende API-Laden, https://docs.microsoft.com/en-us/uwp/api/windows.foundation.metadata.apiinformation
[Windows.Foundation.Metadata.ApiInformation,Windows.Foundation.UniversalAPIContract,ContentType=WindowsRuntime]
# Featureabfrage
[Windows.Foundation.Metadata.ApiInformation]::IsTypePresent("Windows.Media.Playlists.Playlist")
# oder API-Contract mit Version
[Windows.Foundation.Metadata.ApiInformation]::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 1,0)
# bisher bekannte API-Contracts: https://docs.microsoft.com/en-us/uwp/extension-sdks/windows-universal-sdk
# genauer: https://docs.microsoft.com/en-us/uwp/extension-sdks/
@newyear2006
newyear2006 / WindowsRuntimeRadio.PS1
Last active April 21, 2021 15:54
Bluetooth, WLAN und LTE-Modem über Powershell abfragen, ein- und ausschalten und weitere Spielereien mit Bluetooth
# Grundlage: Diese geniale Antwort auf Superuser: https://superuser.com/questions/1168551/turn-on-off-bluetooth-radio-adapter-from-cmd-powershell-in-windows-10/1293303#1293303
# Das Besondere daran, die Verwendung von Async und Await mit WindowsRuntime und alles in purem Powershell!
# hier nur die BluetoothVariante aber man kann durch Ändern der Kind-Abrage nach Wifi, MobileBroadband, FM und Other vorgehen. https://docs.microsoft.com/en-us/uwp/api/windows.devices.radios.radiokind
Function Bluetooth {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus
)
@newyear2006
newyear2006 / GetThunderbirdPassword.CS
Created March 3, 2018 18:00
Firefox oder Thunderbird Passwörter auslesen, hier C# aber als Grundlage für späteres Powershellscript. Bei Thunderbird sind die Passwörter im logins.json file im Profile-Verzeichnis.
using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
/// <summary>
/// A small class to recover Firefox Data
@newyear2006
newyear2006 / IsItPwned.PS1
Created February 28, 2018 12:56
Powershell-Abfrage, ob Passwort sicher ist
Function Get-PwnedPasswordCounter ($password) {
# Hashstring erzeugen
$sha1=[System.Security.Cryptography.SHA1]::Create()
$sha1Hash=$sha1.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($password))
$sha1HashString=[System.BitConverter]::ToString($sha1Hash).Replace('-','')
$hashPrefix=$sha1HashString.Substring(0,5)
$hashSuffix=$sha1HashString.Substring(5)
# pwnedpasswords-API anrufen
@newyear2006
newyear2006 / HyperVVMScreenCopy.PS1
Last active January 14, 2018 14:06
Zum Speichern und Anzeigen des aktuellen Bildschirm einer virtuellen Maschine
#
Add-Type -AssemblyName "System.Drawing"
Add-Type -AssemblyName "System.Windows.Forms"
function Get-VMScreenBMP {
param
(
$VMName,
$index=0
)