Skip to content

Instantly share code, notes, and snippets.

View marobin's full-sized avatar

Marc-Antoine ROBIN marobin

View GitHub Profile
@marobin
marobin / Convert-RegistryFile.ps1
Created May 11, 2025 16:31
Convert a registry file (.reg) to a list of PSCustomObject
Function Convert-RegistryFile {
<#
.SYNOPSIS
Convert a registry file (.reg) to a list of PSCustomObject.
.DESCRIPTION
Convert a registry file (.reg) to a list of PSCustomObject.
This function helps parsing registry files using the rules described in the following page:
https://support.microsoft.com/en-us/topic/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg-file-9c7f37cf-a5e9-e1cd-c4fa-2a26218a1a23
@marobin
marobin / Test-RegistryPolCorruption.ps1
Last active July 9, 2025 08:16
Test whether registry.pol is corrupted
Function Test-RegistryPolCorruption {
[CmdletBinding()]
Param (
[uint32]$Days = 25
)
$Date = (Get-Date).AddDays(-$days)
$RegistryPol = 'C:\Windows\System32\GroupPolicy\Machine\registry.pol'
$RegistryPolFile = Get-Item -Path $RegistryPol -Force -EA Ignore
$Result = $false
@marobin
marobin / MarkOfTheWeb-Functions.ps1
Created October 8, 2024 12:28
Work with Zone.Identifier streams
Function Get-MarkOfTheWeb {
<#
.SYNOPSIS
List the files that have a "Zone.Identifier" stream.
.DESCRIPTION
List the files that have a "Zone.Identifier" stream.
.PARAMETER Path
File or folder where to look for the stream.
@marobin
marobin / ScriptSignature-helpers.ps1
Last active September 25, 2024 14:47
Functions that can be used to sign or unsign PowerShell scripts
Function Write-ScriptSignature {
[CmdletBinding()]
[Alias('signs')]
Param (
# Script(s) path or folder containing the PowerShell scripts to be signed
[Parameter(Mandatory, Position = 0, ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Alias('FullName','LiteralPath')]
[String[]]$Path,
# Certificate issuer name
@marobin
marobin / Convert-RegToPs1.ps1
Created September 17, 2024 15:53
Convert .reg to .ps1
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position = 0)]
[String[]]$Path,
[Parameter(Position = 1)]
[ValidateSet('ascii','bigendianunicode','default','oem','string','unicode','unknown','utf7','utf8','utf8bom','utf32')]
[String]$Encoding = 'utf8bom',
[Switch]$Recurse
@marobin
marobin / Get-SpecialFolder.ps1
Created August 7, 2024 10:02
List all Windows special folders
[Environment+SpecialFolder]::GetNames([Environment+SpecialFolder]) |
Sort-Object |
Select-Object -Property @{Label = 'Name'; Expression = {$_}},
@{Label = 'Path'; Expression = {[Environment]::GetFolderPath("$_")}}
@marobin
marobin / Install-VSCodeAndGit.ps1
Last active May 28, 2025 12:12
Install Visual Studio Code and Git
$Error.Clear()
$VerbosePreference = 'Continue'
#[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleSyntax","", Scope = "Script", Target = "*")]
$wshell = New-Object -ComObject Wscript.Shell
#region logging
$InvocationScriptPath = $MyInvocation.PSCommandPath
if ([String]::IsNullOrEmpty($InvocationScriptPath)) { $InvocationScriptPath = $PSCommandPath }
@marobin
marobin / Write-Log.ps1
Last active April 24, 2025 09:37
Logging function
Function Write-Log {
<#
.SYNOPSIS
Fonction d'écriture de fichier de log.
.DESCRIPTION
Fonction d'écriture de fichier de log.
Cette fonction se sert de plusieurs variables publiques du script :
- $Error : Variable automatique PowerShell
@marobin
marobin / PowerShell-Best-Practice.md
Last active May 28, 2024 13:10
PowerShell Best Practice