Skip to content

Instantly share code, notes, and snippets.

Avatar
💖
Stay warm

Joel Sallow (/u/ta11ow) vexx32

💖
Stay warm
View GitHub Profile
@vexx32
vexx32 / Get-ExceptionStack.ps1
Created Jun 14, 2018
Traverse exception stack for all inner exceptions
View Get-ExceptionStack.ps1
$Exception = $_
$ExceptionStack = @{
OuterException = $_
}
$Increment = 0
while ($Exception.InnerException) {
$Increment++
$Exception = $Exception.InnerException
$ExceptionStack["InnerException$Increment"] = $Exception
}
@vexx32
vexx32 / Export-Png.ps1
Last active Jun 16, 2018
Creates a image from a string of text
View Export-Png.ps1
using namespace System.Drawing
function Export-Png {
[CmdletBinding()]
[Alias('epng')]
param(
[Parameter(
Position = 0,
Mandatory,
ValueFromPipeline
View gist:6900e16745ea24fcf7285860851c223d
foreach ($SMTPAddress in $SMTPs) {
$SMTPAddress |
Get-MoveRequest |
Get-MoveRequestStatistics |
Select DisplayName, @{
Name = 'SMTP'
Expression = $SMTPAddress
}
}
View Thing.ps1
[CmdletBinding()]
param(
[Parameter(Position = 0)]
[ValidateNotNull()]
[PSCredential]
$Credential = [System.Management.Automation.PSCredential]::Empty,
[Parameter(Position = 1)]
[ValidateNotNull()]
[uri]
View SqlThing.ps1
$Data = Invoke-MySQLQuery -ComputerName k1000 -Credential $creds -Query $sql -Database ORG1 |
Where-Object DISK_NAME -MATCH 'Drive C:' |
ForEach-Object {
[PSCustomObject]@{
'Computer Name' = $_.System_Name
'Percent Used' = $_.Percent_Used
'Disk Free' = $_.Disk_Free
'Disk Name' = $_.Disk_Name
'Disk Size' = $_.Disk_Size
'Disk Used' = $_.Disk_Used
View case example.ps1
function Select-Things {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory)]
[string[]]
$Param1
)
if ($Param1 -contains "one") {
switch ($Param1) {
"two" {
View ADPhotoThing.ps1
###COPY and find photos then move and copy to two locations then upload to exchange ##
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;
$OU = "OU=domain,dc=com"
$MissingPhotos = Get-ADUser -SearchBase $OU -Filter * -Properties ThumbNailPhoto, SamAccountName, GivenName, Surname |
Where-Object ThumbnailPhoto -eq $null |
Select-Object SamAccountName, GivenName, Surname |
Sort-Object Surname, GivenName -Descending
View OnceYouSplatYouNeverGoBack.ps1
$TriggerParams = @{
Daily = $true
At = '12am'
ErrorAction = 'Stop'
}
$SettingsParams = @{
ExecutionTimeLimit = [TimeSpan]::FromHours(2)
ErrorAction = 'Stop'
}
$TaskParams = @{
@vexx32
vexx32 / VS Code Settings.json
Created Aug 6, 2018
Personal settings for VS Code
View VS Code Settings.json
{
"files.defaultLanguage": "powershell",
"editor.fontFamily": "'Anonymous Pro', Consolas",
"editor.cursorBlinking": "phase",
"files.autoSave": "onWindowChange",
// Powershell Settings
"powershell.codeFormatting.openBraceOnSameLine": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
View TryGetNumberValue addons.cs
if (suffix == 'u' || suffix == 'U')
{
if (UInt32.TryParse(strNum, style, NumberFormatInfo.InvariantInfo, out uint u))
{
ulong testresult = u * (ulong) multiplier;
if (testresult > UInt32.MaxValue)
{
result = testresult;
}
else