Skip to content

Instantly share code, notes, and snippets.

View awakecoding's full-sized avatar

Marc-André Moreau awakecoding

View GitHub Profile
@awakecoding
awakecoding / PascalSnakeCase.ps1
Created January 22, 2020 01:02
PowerShell ConvertTo-PascalCase, ConvertTo-SnakeCase
function ConvertTo-PascalCase
{
[OutputType('System.String')]
param(
[Parameter(Position=0)]
[string] $Value
)
# https://devblogs.microsoft.com/oldnewthing/20190909-00/?p=102844
return [regex]::replace($Value.ToLower(), '(^|_)(.)', { $args[0].Groups[2].Value.ToUpper()})
@awakecoding
awakecoding / mongo-lock.ps1
Created February 9, 2020 17:55
Simple script to reproduce remaining WiredTiger.lock lock file issue observed with MongoDB Windows container: https://github.com/docker-library/mongo/issues/385
# Simple script to reproduce remaining WiredTiger.lock
# lock file issue observed with MongoDB Windows container:
# https://github.com/docker-library/mongo/issues/385
function Remove-MongoLock
{
param(
[string] $VolumeName
)
$Features = @(`
'Web-Server',
'Web-Http-Errors',
'Web-Http-Logging',
'Web-Static-Content',
'Web-Default-Doc',
'Web-Dir-Browsing',
'Web-AppInit',
'Web-Net-Ext45',
@awakecoding
awakecoding / Get-Netstat.ps1
Created September 26, 2020 02:51
PowerShell netstat wrapper
function Get-Netstat
{
$netstat = Get-Command -Name 'netstat' -ErrorAction SilentlyContinue
if (-Not $netstat) {
Write-Warning "netstat command not available"
return ,@()
}
@awakecoding
awakecoding / PSSecureCommand.ps1
Created November 30, 2020 21:30
Launch a new PowerShell instance and send secure commands to it that won't be leaked in command-line parameters, environment variables or the console history.
function Invoke-PSCmdClient
{
param(
[Parameter(Position=0)]
[string] $PipeName
)
$Pipe = [System.IO.Pipes.NamedPipeClientStream]::new('.', $PipeName,
[System.IO.Pipes.PipeDirection]::In)
@awakecoding
awakecoding / New-ModulePackage.ps1
Last active October 25, 2023 19:21
New-ModulePackage: create a PowerShell module nuget package without publishing it like Publish-Module does
function New-ModulePackage
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $InputPath,
[Parameter(Mandatory=$true,Position=1)]
[string] $OutputPath,
[string] $TempPath
@awakecoding
awakecoding / Invoke-VMAutologon.ps1
Last active April 12, 2024 06:05
Invoke-VMAutologon.ps1
function Invoke-VMAutologon
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $VMName,
[Parameter(Mandatory=$true)]
[string] $UserName,
[string] $DomainName = ".\",
@awakecoding
awakecoding / New-IsoFile.ps1
Created April 20, 2021 01:58
New-IsoFile.ps1
#
# New-IsoFile: simple PowerShell function to create iso file from a directory
#
# This is heavily simplified code inspired from:
# https://blog.apps.id.au/powershell-tools-create-an-iso/
# http://blogs.msdn.com/b/opticalstorage/archive/2010/08/13/writing-optical-discs-using-imapi-2-in-powershell.aspx
# http://tools.start-automating.com/Install-ExportISOCommand/
# http://stackoverflow.com/a/9802807/223837
function New-IsoFile
@awakecoding
awakecoding / AlpineOverlay.ps1
Created April 22, 2021 00:25
Windows Alpine Overlay Expand/Compress functions
function Expand-AlpineOverlay
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $InputFile,
[Parameter(Mandatory=$true,Position=1)]
[string] $Destination,
[switch] $Force
)
@awakecoding
awakecoding / pwsh-oras-manifest.ps1
Created September 16, 2021 14:52
Fetch PowerShell release information and convert to an ORAS artifact manifest
# Fetch latest PowerShell release information from GitHub and export ORAS manifest
$Headers = @{
Accept = "application/vnd.github.v3+json";
}
$RequestParams = @{
Method = 'GET';
Headers = $Headers;