Skip to content

Instantly share code, notes, and snippets.

View steviecoaster's full-sized avatar
🤠
It's a sweet day to write some Powershell

Stephen Valdinger steviecoaster

🤠
It's a sweet day to write some Powershell
View GitHub Profile
@steviecoaster
steviecoaster / New-RandomPass.ps1
Last active December 10, 2024 23:31
Cross platform password generator
function New-RandomPass {
<#
.Synopsis
Generates and returns a suitably secure password
.EXAMPLE
New-RandomPass
Returns a random password as a SecureString object
.EXAMPLE
@steviecoaster
steviecoaster / Copy-CertToStore.ps1
Last active December 6, 2024 17:12
Copy a x509 certificate from one windows store to another
function Copy-CertToStore {
<#
.SYNOPSIS
Copy a certificate from one store location to another
.DESCRIPTION
Long description
.PARAMETER Certificate
The certificate to copy
@steviecoaster
steviecoaster / dogs.ps1
Created December 2, 2024 18:08
Evaluate breed in a collection
$breeds = @('Labrador','Poodle','St. Bernard','Husky')
'mut' -in $breeds # false
'Poodle' -in $breeds #true
@steviecoaster
steviecoaster / Explaination.md
Last active November 28, 2024 14:58
Use a module from another machine with Implicit remoting

Implicit Remoting explained

Implicit remoting allows you to load a module from a remote session and execute it "locally". What you are actually doing is running a proxy command. The actual function executes on the remote session, and the data is returned to you locally.

This approach does have the same caveats as running a command directly via Invoke-Command in that it is deserialized and rehydrated, losing any available methods on the object.

This is still a hugely useful trick, and I highly recommend using a prefix so you know in your code when something is running on the remote system. For example Get-ADComputer may become Get-RemoteADComputer. You can specify whatever prefix you want, just make it

@steviecoaster
steviecoaster / New-EncryptedEnvironmentVariable.ps1
Last active November 22, 2024 15:00
Write an encrypted Environment variable
function New-EncryptedEnvironmentVariable {
<#
.SYNOPSIS
Writes an Environment variable as a secure string using DPAPI
.DESCRIPTION
Writes an Environment variable as a secure string using DPAPI
.PARAMETER Scope
The scope of the variable. Can be machine, user, or process
@steviecoaster
steviecoaster / hiddenparam.ps1
Created November 19, 2024 18:56
Demonstrating hidden params
function Hide-Param {
[CmdletBinding()]
Param(
[Parameter(DontShow)]
[String]
$SecretValue
)
end {
@steviecoaster
steviecoaster / Microsoft.PowerShell_profile.ps1
Last active January 28, 2025 03:31
My PowerShell Profile script
function Get-OutdatedChocoPackage {
[Alias('outdated')]
[Cmdletbinding()]
Param(
)
choco outdated --limit-output |
ConvertFrom-Csv -Delimiter '|' -Header Id, InstalledVersion, AvailableVersion, Pinned |
Select-Object Id, InstalledVersion, AvailableVersion, @{N = 'Pinned'; E = { [Bool]::Parse($_.Pinned) } } |
Where-Object { [version]$_.AvailableVersion -gt [version]$_.InstalledVersion }
}
@steviecoaster
steviecoaster / keybase.md
Created September 24, 2024 14:36
keybase proof

Keybase proof

I hereby claim:

  • I am steviecoaster on github.
  • I am steviecoaster (https://keybase.io/steviecoaster) on keybase.
  • I have a public key ASAkTmyMBHZACWCaR9NaOul6cuOhuucZnNnjUZRxXXIqDQo

To claim this, I am signing this object:

@steviecoaster
steviecoaster / New-QueryString.ps1
Last active November 25, 2024 23:42
Creates a querystring to use with an API call
function New-QueryString {
<#
.SYNOPSIS
Turn a hashtable into a URI querystring
.DESCRIPTION
Turn a hashtable into a URI querystring
.PARAMETER QueryParameter
The hashtable to transform
@steviecoaster
steviecoaster / Set-CollectionOrder.ps1
Created September 5, 2024 01:49
Reorder items in a collection
function Set-CollectionOrder {
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[System.Collections.Generic.List[string]]
$Collection,
[Parameter(Mandatory)]
[String]
$Item,