Skip to content

Instantly share code, notes, and snippets.

Avatar

Dustin Dortch dustindortch

View GitHub Profile
@dustindortch
dustindortch / TeslaCam.ps1
Created Nov 28, 2019
Creating a Sentry Mode disk for a Tesla with PowerShell (Assuming the G drive is the desired volume)
View TeslaCam.ps1
Format-Volume -DriveLetter G -FileSystem FAT32 -Full -Force
New-Item -Path G:\ -Name 'TeslaCam' -Type Directory
View prompt.ps1
$forePromptColor = 0
[System.Collections.Generic.List[ScriptBlock]]$global:PromptRight = @(
# right aligned
{ "$FG;${er}m{0}" -f $LeftArrow }
{ "$FG;${forePromptColor}m$BG;${er}m{0}" -f $(if (@(get-history).Count -gt 0) {(get-history)[-1] | % { "{0:c}" -f (new-timespan $_.StartExecutionTime $_.EndExecutionTime)}}else {'00:00:00.0000000'}) }
{ "$FG;7m$BG;${er}m{0}" -f $LeftArrow }
{ "$FG;0m$BG;7m{0}" -f $(get-date -format "hh:mm:ss tt") }
)
View Infrastructure as Code: Azure AD Group Creation
# Pester testing
## Prep work
## Depends - Pester, AzureADPreview, and xAzureAD.DirectorySettings modules
## Get original values - Get-AzureADDirectorySetting -Name Group.Unified | Export-Csv <Path> -NoTypeInformation
$ExpectedSettings = Import-Csv <Path>
Describe 'Azure AD Group Creation Settings' {
$ActualSettings = Get-AzureADDirectorySetting -Name Group.Unified
View Never ending while loop
While ($True) {
Write-Output "This is my output"
Get-Date
Start-Sleep -s 300 # Sleep for 5 minutes
}
View Get-Food
Function Get-Food {
Param(
[Parameter(ValueFromPipeline)]
[String[]]$Types
)
$Seed = Get-Random -Minimum 0 -Maximum $($Types.Count - 1)
Write-Output $Types[$Seed]
}
View Tacos or Gyros
Function Get-TacosOrGyros {
$Seed = Get-Random -Minimum 0 -Maximum 100
If(($Seed % 2) -eq 0) {
Write-Output "Tacos"
} Else {
Write-Output "Gyros"
}
}
View Verbose examples
Function Get-CmdletbindingExample {
[CmdletBinding()]
Param (
[String[]]$Name
)
Begin {# Runs once}
Process {
# Runs for each instance of $Name
View Cmdletbinding Function
Function Get-CmdletbindingExample {
[CmdletBinding()]
Param (
[String[]]$Name
)
Begin {# Runs once}
Process {# Runs for each instance of $Name}
View JoinedTeams
/beta/me/joinedTeams