Skip to content

Instantly share code, notes, and snippets.

View pinecones-sx's full-sized avatar

Pinecones pinecones-sx

View GitHub Profile
@pinecones-sx
pinecones-sx / Find-MappedDrives.ps1
Created September 5, 2019 00:12
Finds mapped drives on local machine or via AD computers
<# Find-MappedDrives
Finds and returns all logically mapped drives from a computer
#>
function Find-MappedDrives {
param(
$Target = 'localhost',
[switch]$All
@pinecones-sx
pinecones-sx / GUI-AppXUninstaller.ps1
Last active June 15, 2019 03:53
powershell based gui frontend for appx package uninstallation (to remove windows apps from all existing and new profiles)
<# to do:
- sort apps by name in GUI
- add check-boxes in main form to change results (see next two items)
- include programs and features apps
- include optional listing of built-in MS apps
- see if you can straighten out naming and icons for AppX apps (so it looks nicer)
#>
# Functions & libs
@pinecones-sx
pinecones-sx / this-formsucks.ps1
Last active June 6, 2019 03:05
form is displaying offset control
<#
Panel should display centered in the form. Instead it display offset to the right and bottom.
#>
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
[void][Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[void][Reflection.Assembly]::LoadWithPartialName('System.Drawing')
# Main form
$formToolbox = New-Object System.Windows.Forms.Form
@pinecones-sx
pinecones-sx / get-appxicon.ps1
Created June 5, 2019 03:16
to get icons from appx package
$results = (
Get-AppxPackage |
ForEach{
$thisAppx = $_
$thisManifest = $_ | Get-AppxPackageManifest
$thisSubPath = ''
$thisLogoBaseName = ''
$thisLogoRoot = ''
$thisLogoUNC = ''
If ($thisManifest.Package.Properties.logo -like '*\*'){
@pinecones-sx
pinecones-sx / BADBUTTONS.ps1
Created May 23, 2019 00:47
the button control is appearing too far to the right for some insane reason
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
Add-Type -AssemblyName System.Windows.Forms, System.Drawing
$formToolbox = New-Object System.Windows.Forms.Form
$formToolbox.Size = New-Object System.Drawing.Size(300,400)
$formToolbox.StartPosition = 'CenterScreen'
$formToolbox.SizeGripStyle = 'Hide'
$formToolbox.ShowInTaskbar = $true
$iconToolbox = New-Object system.drawing.icon $windowIconUNCPath
$formToolbox.Icon = $iconToolbox
# List of accepted app parameters
$appSet = 'PowerShell','Chrome','FireFox','Reader'
#STUB# If (Test-Path ($pathToFileWithNames)){$appSet = $importedFileStringArray}
# ps 2.0 compatible enum for accepted app names == [ChocoApp]
Add-Type -TypeDefinition "public enum ChocoApp {$($appSet -join ',')}"
Function Load-Chocolatey{
If (-not $env:ChocoInstalled){
# install
@pinecones-sx
pinecones-sx / convert-nonsensecsv.ps1
Last active October 24, 2018 22:08
function to fix awful FortiAnalyzer exports
u<# Format-FortiAnalyzerReport
Fixes terribad formatting from FortiAnalzyer CSV exports.
Use:
Format-FortiAnalyzerReport <UNC Path to CSV> -SaveCopy
-FileName
UNC path of the CSV to fix.
-SaveCopy
@pinecones-sx
pinecones-sx / Extract-Icons.ps1
Created October 16, 2018 20:44
Powershell script to extract HQ icons
<# Extract-Icons
Requires iconsext.exe from:
http://www.nirsoft.net/utils/iconsext.html
No documentation because I'm lazy.
I needed something to extract high resolution icons and couldn't find a definite
answer so i just reused a CMD compatible free program.
#>
@pinecones-sx
pinecones-sx / pass-functions.ps1
Created December 13, 2017 18:57
pass local functions to remote session with invoke-command
<# Passing functions to remote sessions
https://stackoverflow.com/questions/11367367/how-do-i-include-a-locally-defined-function-when-using-powershells-invoke-comma
#>
function test-write {Write-Host 'i pood!'}
function test-out {'i pood!' | Out-File 'C:\users\public\documents\test.txt'}
$passedFunctions = "function test-write {${function:test-write}} ; function test-out {${function:test-out}}"
$targetPC = 'PC1'
@pinecones-sx
pinecones-sx / Get-Winner.ps1
Last active June 22, 2017 19:55
uses an OU in active directory to find raffle winners. prevents users from winning multiple times.
# Required scripts -- this just loats the AD snapin or calls it remotely from a DC
.'\\ps1\functions\Import-AD.ps1'
$env:winnerListUNC = '\\DomainName.local\filestore\winnerList.txt'
$env:userOUSearchBase = 'OU=TheUsers,DC=DomainName,DC=local'
function global:Get-Winner {
param(
$ExcludedUsers,