Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyTBradshaw/6f198866d1c956fc9f9548b517c48f37 to your computer and use it in GitHub Desktop.
Save JeremyTBradshaw/6f198866d1c956fc9f9548b517c48f37 to your computer and use it in GitHub Desktop.
PS $Profile
using namespace System
using namespace System.Runtime.InteropServices
########-----------#
#region# Variables #
########-----------#
try {
$Cred1 = Import-Clixml "$($HOME)\Cred1.xml" -ErrorAction Stop
Write-Information -MessageData "`$Cred1: $($Cred1.UserName)" -InformationAction Continue
}
catch {}
###########-----------#
#endregion# Variables #
###########-----------#
########-----------#
#region# Functions #
########-----------#
function prompt {
"`n[PS] $([datetime]::Now.ToString('yyyy-MM-dd h:mm:ss tt (zzzz)'))`n$($PWD)`n`n$('>' * ($NestedPromptLevel + 1)) "
}
function Set-WindowTitle ($Text) {
$Host.UI.RawUI.WindowTitle = $Text
}
function New-Guid ([ValidateRange(1, 10)][int]$Count = 1) { 1..$Count | Foreach-Object { [Guid]::NewGuid() } }
function New-FakeThumbprint ([ValidateRange(1, 10)][int]$Count = 1) {
1..$Count | ForEach-Object {
(
1..40 | Foreach-Object {
Get-Random @('A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
}
) -join ''
}
}
function ConvertFrom-GuidToImmutableId ([Guid]$Guid) {
[Convert]::ToBase64String([Guid]::Parse($Guid).ToByteArray())
}
function ConvertFrom-ImmutableIdToGuid ([string]$ImmutableId) {
[Guid]([Convert]::FromBase64String($ImmutableId))
}
function ConvertFrom-SecureStringToPlainText ([SecureString]$SecureString) {
[Marshal]::PtrToStringAuto(
[Marshal]::SecureStringToBSTR($SecureString)
)
}
###########-----------#
#endregion# Functions #
###########-----------#
########---------#
#region# Aliases #
########---------#
New-Alias -Name t -Value Set-WindowTitle
New-Alias -Name imo -Value Import-Module
New-Alias -Name ng -Value New-Guid
New-Alias -Name nft -Value New-FakeThumbprint
New-Alias -Name g2i -Value ConvertFrom-GuidToImmutableId
New-Alias -Name i2g -Value ConvertFrom-ImmutableIdToGuid
New-Alias -Name s2p -Value ConvertFrom-SecureStringToPlainText
###########---------#
#endregion# Aliases #
###########---------#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment