Skip to content

Instantly share code, notes, and snippets.

View gravejester's full-sized avatar

Øyvind Kallstad gravejester

View GitHub Profile
[System.Diagnostics.CodeAnalysis.SuppressMessage('AvoidUsingPlainTextForPassword', '', Target='ProcessParameter')]
[CmdletBinding()]
param (
[Parameter()]
[Alias('SPName','Username','un')]
[string] $ServicePrincipalName,
[Parameter()]
[Alias('SPPassword','Password','pw')]
[string] $ServicePrincipalPassword,
[CmdletBinding(DefaultParameterSetName = 'Credential')]
param (
[Parameter(ParameterSetName = 'Credential')]
[System.Management.Automation.PSCredential] $Credential,
[Parameter(ParameterSetName = 'ClearText')]
[string] $ApplicationId,
[Parameter(ParameterSetName = 'ClearText')]
[string] $Password,
adm cmd:
install node for windows
- node v6.10.3
- npm 3.10.10
cd c:\..\..\EditorSyntax
npm init
function Update-AzureRmTag {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
[string[]] $ResourceId,
[Parameter()]
[hashtable] $Tags = [hashtable]::new()
)

Keybase proof

I hereby claim:

  • I am gravejester on github.
  • I am okallstad (https://keybase.io/okallstad) on keybase.
  • I have a public key ASBM-6vpDIBHoXbDogydKGLwjT3NC_7iy7EtFJ6ApHawSwo

To claim this, I am signing this object:

@gravejester
gravejester / CRC.ps1
Last active November 28, 2021 22:48
function Get-CRC32 {
<#
.SYNOPSIS
Calculate CRC.
.DESCRIPTION
This function calculates the CRC of the input data using the CRC32 algorithm.
.EXAMPLE
Get-CRC32 $data
.EXAMPLE
$data | Get-CRC32
# Add custom type with static method
Add-Type -MemberDefinition @"
public static string SayHello()
{
string Hello = "Hello";
return Hello;
}
"@ -Name Stuff -Namespace My
# Define custom function calling my custom type
function Test-WebRequest {
<#
.SYNOPSIS
Test web request.
.DESCRIPTION
This function can be used to test a web request to a URI. It functions similarly to Test-Path and will either return
True or False.
.EXAMPLE
Test-WebRequest 'google.com'
This should return True.
function Invoke-StreamData {
[CmdletBinding()]
param (
[switch] $ShowWarning,
[switch] $ShowError
)
Write-Host "This is written to the host"
Write-Verbose "This is written to the verbose stream"
Write-Output "This is written to the output stream"
function ConvertTo-GUID {
[CmdletBinding()]
param (
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $ImmutableId
)
try {
$byteArray = [Convert]::FromBase64String($ImmutableId)
$newGuid = [Guid]::new($byteArray)