Skip to content

Instantly share code, notes, and snippets.

@Diagg
Diagg / Convert-DsRegCmd.ps1
Last active March 2, 2026 18:10
Convert DsRegCmd to a Powershell object with a oneliner
# Inspiration from https://gist.github.com/d4rkeagle65/b9bc42a26be44a6d66c4858a4c3bc944 by d4rkeagle65
# Output to object by Diagg/OSD-Couture.com
$Dsregcmd = New-Object PSObject ; Dsregcmd /status | Where {$_ -match ' : '}|ForEach {$Item = $_.Trim() -split '\s:\s'; $Dsregcmd|Add-Member -MemberType NoteProperty -Name $($Item[0] -replace '[:\s]','') -Value $Item[1] -EA SilentlyContinue}
# to vue full objest type : $Dsregcmd
# to vue property TenantID : $Dsregcmd.TenantId
@Diagg
Diagg / OSFriendlyBuild.ps1
Created October 12, 2021 22:08
how to retrieve meaningful (like 21H2) build number from the internet. (Support Windows 10 and 11)
# OSFriendlyBuild.ps1 by Diagg/OSD-Couture.com
$OSBuild = @{}
$BuildNumber = (Get-ItemProperty 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion').CurrentBuild
IF ([int]($BuildNumber) -lt 22000){$HTML = Invoke-RestMethod 'https://docs.microsoft.com/en-us/windows/release-health/release-information'}
else {$HTML = Invoke-RestMethod 'https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information'}
$Pattern = '<strong>(?<version>.*)<\/strong>'
$AllMatches = ($HTML | Select-String $Pattern -AllMatches).Matches
($AllMatches.Groups | Where-Object {$_.name -eq 'version'}).value -replace "Version " -replace "\(RTM\) " -replace "\(original release\) " -replace "\(OS build" -replace "\)"| ForEach-Object {$Htbl = $_ -split " "; $OSBuild[$Htbl[2]] = $Htbl[0]}
Try {[System.Environment]::SetEnvironmentVariable('OSBUILD',$OSBuild[$buildnumber],'Machine')}
@Diagg
Diagg / Parse-BCDEdit.ps1
Created October 25, 2021 23:32
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('-'))
{
@Diagg
Diagg / Invoke-ScheduledTask.ps1
Created November 15, 2021 00:05
This function will help showing user interface when using client in system context like SCCM, Intune or Workspace One.
Function Invoke-ScheduledTask
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[String]$TaskName,
[Parameter(Mandatory = $true)]
[String]$command,
[Parameter(Mandatory = $false)]
[string]$Parameters,