This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ( -not $env:ConEmuPID ) { | |
| function global:prompt { | |
| $E = "$([char]27)" | |
| $F = "$E[38;5" | |
| $B = "$E[48;5" | |
| "$B;255m$F;0mI $F;1m$([char]9829) $F;0mPS $F;0m$B;255m$([char]8250)$E[0m " | |
| } | |
| } | |
| else { | |
| [List[ScriptBlock]]$global:Prompt = @( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Contents of MyFile.csv | |
| # | |
| #To,Subject,Body | |
| #firstguy@fake.tld,subject1,<p>body</p> | |
| #secondguy@fake.tld,subject2,<i>italic body</i> | |
| $csvContents = Import-Csv MyFile.csv | |
| $defaultEmailParams = @{ | |
| 'SmtpServer' = 'EmailRelay' | |
| 'BodyAsHtml' = $true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Invoke-Test { | |
| param ( | |
| [parameter()][string]$Parameter | |
| ) | |
| Get-Childitem -Path $Parameter -Depth $two -Recurse | |
| $two = 2 | |
| Get-ChildItem -Path $three | |
| Get-Childitem -Path $Parameter -Depth $two -Recurse | |
| $five = 'something' | |
| $five -eq $true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Wait-YoutubeVid { | |
| param ( | |
| [Parameter( Mandatory )] | |
| [string]$VideoUrl, | |
| [Parameter( Mandatory )] | |
| [string]$ApiKey | |
| ) | |
| $videoId = [regex]::Matches($VideoUrl, '(?<=([V|v]=)).+?(?=\b)').Value | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while($true){ | |
| write-output $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('eQBlAHMAIABpAG4AZABlAGUAZAA='))) | |
| if ( | |
| $(Get-Date -f yyyy) -eq ( | |
| Get-Date -f yyyy) | |
| ){ | |
| write-output $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('aABhAGgAbABvAGwA'))) | |
| break | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #don't store names and members in variables like this | |
| #don't name variables like this | |
| #handle hashtable "already contains key" errors better than this | |
| #don't do this | |
| $list1 = 'list1 name' | |
| $list1mem = @('list 1 members') | |
| $list2 = 'list2 name' | |
| $list2mem = @('list 2 members') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-SearchResults { | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(Mandatory,Position=0)] | |
| [string]$SearchTerms | |
| ) | |
| $searchURL = "http://www.bing.com/search?q=$([System.Web.HttpUtility]::UrlEncode($searchTerms))" | |
| $searchResults = Invoke-WebRequest $searchURL | |
| $searchResults.links | ? { $_.href -match 'http' } | select innertext,href -first 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (get-command gimme-exchange).definition | |
| $arrExchangeServersURI = @("http://redacted/Powershell","http://redacted2/Powershell") | |
| $success = $false | |
| ForEach ($connectionURI in $arrExchangeServersURI) | |
| { | |
| Try | |
| { | |
| If($success -ne $true) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $groups = import-csv "$(get-temp)\groups.csv" | |
| foreach ($gr in $($groups.group)) | |
| { | |
| Get-ADGroupMember $gr | % { Get-ADUser $_.SamAccountName -properties Enabled } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $UTCTime = $(whatever-code-got-you-utc-time) | |
| $strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName | |
| $TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone) | |
| $LocalTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ) |