Code Snippets PowerShell

Short texts PowerShell 🧑‍💻 Code snippets PowerShell ✍️ Reading lists PowerShell 👀

Parse BCDedit enumation to a Powershell Object

## Parse BCDedit enumation to a Powershell Object ## By Diagg/OSDC – 26/10/2021 ## Usage exemple: $Bcdedit|where Index -eq 0|select default $ObjName = $null ; $Val = 0 ; $Index = 0 ; $Bcdedit = @() $BcdString = bcdedit /v $BcdString|Foreach { If ($_.startswith(‘-‘)) { If ($ObjName -ne $null -and $ObjName.Name -ne $BcdString[$Val-1]){$Bcdedit += $ObjName} […]

ohmyposh settings

{ “$schema”: “https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json”, “console_title”: true, “console_title_style”: “template”, “console_title_template”: “{{if .Root}}(Admin) {{end}}{{.Folder}}”, “blocks”: [ { “type”: “prompt”, “alignment”: “left”, “segments”: [ { “type”: “root”, “style”: “powerline”, “powerline_symbol”: “\uE0C4”, “foreground”: “#242424”, “background”: “#f1184c”, “properties”: { “prefix”: “”, “postfix”: “” } }, { “type”: “os”, “style”: “diamond”, “leading_diamond”: ” “, “powerline_symbol”: “”, “foreground”: “#3A86FF”, “background”: “#282c34”, “properties”: { […]

PowerShell Profile

using namespace System.Management.Automation using namespace System.Management.Automation.Language if ($host.Name -eq ‘ConsoleHost’) { Import-Module PSReadLine } #Import-Module PSColors #Import-Module posh-git Import-Module -Name Terminal-Icons Import-Module oh-my-posh set-alias desktop “Desktop.ps1” #Set-Theme ParadoxGlucose #Set-PoshPrompt -theme “D:\Dropbox\poshv3.json” oh-my-posh –init –shell pwsh –config “D:\Dropbox\poshv3.json” | Invoke-Expression Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new() […]

Provision Win 10 with a WSL Host Machine Fedora Driven Podman

# Instructions: # Requires Windows 10 with WSL2 installed (wsl –install on recent builds) # Open a powershell console # Cut and paste: # iex (Invoke-WebRequest “https://gist.github.com/n1hility/d29cb429ab3714a2c644b6e645d62a21/raw/” -UseBasicParsing) $containers = “[containers]`n” + “netns=`”slirp4netns`”`n” + “`n” + “[engine]`n” + “cgroup_manager = `”cgroupfs`”`n” + “events_logger = `”file`”” $bootstrap = “#!/bin/bash`n” + “`n” + “if [ ! -f […]