Skip to content

Instantly share code, notes, and snippets.

View noahpeltier's full-sized avatar

TismaticTech noahpeltier

View GitHub Profile
@noahpeltier
noahpeltier / Admin Toolbox.ps1
Last active May 9, 2022 14:29
Admin tool box I created for work
#===================================================================
# Admin ToolBox
# Created by: Noah Peltier
# Version 4.0
# Email: noah.peltier@gmail.com
#
# Requires RSAT - https://www.microsoft.com/en-us/download/details.aspx?id=7887
#
#===================================================================
# This is a way to store your own credentials for backup or use in other scripts as a password manager
(Get-credential -Message "Please log in to continue").GetNetworkCredential() | Select UserName, Password | ft -AutoSize | out-host
#Out-Host can be anything really. The password is stored in plain text so you'd need to encript it as a pscredential or something for safety
@noahpeltier
noahpeltier / Invoke-apaste
Created August 12, 2018 18:45
Running a script from apaste URL
$data = (Invoke-WebRequest -Uri "https://apaste.info/LgTm").Content
$data2 = $data -replace '<[^>]+>','' -replace "Apache Paste Bucket" -replace "Showing paste" -replace "&quot;" , '"' -replace "Make a new paste"
iex $data2
@noahpeltier
noahpeltier / log
Last active January 9, 2019 20:28
A new line
Class Computer {
[String]$Name
[String]$Description
[String]$Type
[String]$Owner
[int]$Reboots
Computer ([string]$Name,$description,$Type,$Owner){
$this.name = $Name
function Convert-WuaResultCodeToName
{
param( [Parameter(Mandatory=$true)]
[int] $ResultCode
)
$Result = $ResultCode
switch($ResultCode)
{
2
{
@noahpeltier
noahpeltier / Drag a winform
Created March 8, 2019 16:36
Stick this in a win forms app to make it drag-able
$global:dragging = $false
$global:mouseDragX = 0
$global:mouseDragY = 0
$form1.Add_MouseDown( { $global:dragging = $true
$global:mouseDragX = [System.Windows.Forms.Cursor]::Position.X - $form1.Left
$global:mouseDragY = [System.Windows.Forms.Cursor]::Position.Y -$form1.Top
})
$form1.Add_MouseMove( { if($global:dragging) {
@noahpeltier
noahpeltier / gmailnotify.ps1
Last active September 27, 2023 11:22
Gmail notification with File contents when one is placed in a specified directory
$FileSystemWatcher = New-Object System.IO.FileSystemWatcher
$FileSystemWatcher.Path = "C:\temp"
Register-ObjectEvent -InputObject $FileSystemWatcher -EventName Created -Action {
$Object = "{0} was {1} at {2}" -f $Event.SourceEventArgs.FullPath,
$Event.SourceEventArgs.ChangeType,
$Event.TimeGenerated
$Event.SourceEventArgs.FullPath
Add-Type -AssemblyName presentationCore
$Player = New-Object system.windows.media.mediaplayer
$player.Open("http://djbloom.info/Music/My%20Music/AC%20DC/06%20Back%20in%20Black.wma")
$player.Play()
@noahpeltier
noahpeltier / connectexchange.ps1
Created April 22, 2019 16:28
Connects to Exchange online in a consol
$SessionParams = @{
ConfigurationName = "Microsoft.Exchange"
ConnectionUri = "https://outlook.office365.com/powershell-liveid/"
Credential = $Credential
Authentication = "Basic"
AllowRedirection = $true
}
Try {
Write-Host "Creating session to $($SessionParams.ConnectionUri)" -ForegroundColor Cyan