Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Logged into org account

Brett Miller brettmillerb

💭
Logged into org account
View GitHub Profile
View Test-DivisibleByThree
function Test-DivisibleByThree {
[CmdletBinding()]
[OutputType([String])]
Param (
[Parameter(Mandatory=$true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
$String
)
@brettmillerb
brettmillerb / HowTo.md
Last active Aug 28, 2020
Teams JSON String Creation of Teams Webhook Content
View HowTo.md

I wanted a way to dynamically build output in Azure Automation for a database migration.

# Create the internal sections first with ElasticPoolName and databases joined with \n\n (new line in Teams)
$sections = $dbsPerElasticPool | ForEach-Object {
    New-TeamsSection -ActivityTitle ('ElasticPool: **{0}**' -f $_.ElasticPool) -Value ($_.databases -join '\n\n')
}

# Create the rest of the card with the sections
$card = New-TeamsMessageCard -Sections $sections | ConvertTo-Json -Depth 5
View zshrc-theme
# Path to your oh-my-zsh installation.
export ZSH="/Users/brett.miller/.oh-my-zsh"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# Set name of the theme to load
ZSH_THEME="powerlevel9k/powerlevel9k"
DISABLE_AUTO_TITLE="true"
# Plugins
@brettmillerb
brettmillerb / Example.md
Created Jun 16, 2020
Splunk New-SearchQuery
View Example.md
$newSearchQuerySplat = @{
    index = 'sitescope3' 
    SlAppId = 'alteryx' 
    SlStatusMessage = 'cpu', 'memory' 
    SlMonName = 'prod' 
    SourceType = 'sitescope' 
    HostName = 'hidden'
}
@brettmillerb
brettmillerb / EditorServicesCommandSuiteError.ps1
Last active Jun 15, 2020
Error for EditorServicesCommandSuite MacOS
View EditorServicesCommandSuiteError.ps1
System.Management.Automation.MethodInvocationException: Exception calling "ProcessRecord" with "1" argument(s): "Method not found: 'Int64 Microsoft.PowerShell.EditorServices.Extensions.ILspFilePosition.get_Line()'."
---> System.MissingMethodException: Method not found: 'Int64 Microsoft.PowerShell.EditorServices.Extensions.ILspFilePosition.get_Line()'.
at EditorServicesCommandSuite.EditorServices.ContextService.GetDocumentContextAsync(PSCmdlet cmdlet, CancellationToken cancellationToken, ThreadController threadController)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at EditorServicesCommandSuite.EditorServices.ContextService.GetDocumentContextAsync(PSCmdlet cmdlet, CancellationToken cancellationToken, ThreadController threadController)
at EditorServicesCommandSuite.Internal.RefactorCmdletAdapter.<>c__DisplayClass12_0.<<InvokeRefactor>b__0>d.MoveNext() in D:\a\1\s\src\EditorServicesCommandSuite\Internal\RefactorCmdletAdapter.cs:line 126
View sparse-checkout.md

Create a directory on your local machine

PS > New-Item -ItemType Directory -Name SharePointOnline-ScriptSamples

Directory: /Users/brett.miller/git/gitpersonal
Mode       LastWriteTime        Length Name
----       ------------ -       ------ ----
d----       24/04/2020  15:03          SharePointOnline-ScriptSamples
View servicenowuser.ps1
# Eg. User name="admin", Password="admin" for this code sample.
$user = "admin"
$pass = "admin"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization', ('Basic {0}' -f $base64AuthInfo))
@brettmillerb
brettmillerb / profile.ps1
Last active Oct 16, 2021
Mac Pwsh Profile
View profile.ps1
Import-Module -Name Toolbox
Import-Module -Name Microsoft.PowerShell.UnixCompleters
Import-Module -Name Terminal-Icons
function BackOne {
Set-Location ..
}
function BackTwo {
Set-Location ../..
}
View HalbaradRequest.ps1
HelpUri : https://go.microsoft.com/fwlink/?LinkID=113308
ResolvedCommandName : Get-ChildItem
DisplayName : gci -> Get-ChildItem
ReferencedCommand : Get-ChildItem
ResolvedCommand : Get-ChildItem
Definition : Get-ChildItem
Options : ReadOnly
Description :
OutputType : {System.IO.FileInfo, System.IO.DirectoryInfo}
Name : gci