Skip to content

Instantly share code, notes, and snippets.

View AndrewPla's full-sized avatar
🌠
Shooting for the stars!

Andrew Pla AndrewPla

🌠
Shooting for the stars!
View GitHub Profile
@rkeithhill
rkeithhill / powershell.json
Last active February 23, 2024 23:18
PowerShell snippets file for Visual Studio Code - place in your ~\AppData\Roaming\Code\User\Snippets directory
{
"Condition statement": {
"prefix": "cond",
"body": [
"$1 { $0; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {
"prefix": "condsqstr",
@JustinGrote
JustinGrote / Get-AllLocalGroupAdmins.ps1
Created May 27, 2016 23:12
Get-AllLocalGroupAdmins - Get Active Computers in AD and return the local Administrator group membership. Report as Excel.
#requires -version 5.0
<#
.SYNOPSIS
Finds active computers in AD and collects a list of their group memberships
#>
param (
#Path to output the resulting Excel Report
[String]$Path = "LocalAdminGroupReport-$(get-date -format yyyyhhmmss).xlsx",
@magnetikonline
magnetikonline / README.md
Last active April 29, 2024 23:45
PowerShell execute command (.exe) with arguments safely (e.g. with spaces).

PowerShell execute command with arguments safely

In my opinion this is the best way for executing external commands from PowerShell with arguments in a safe manner - via the use of an array to hold the arguments.

Consider this one a PowerShell gem to keep in the toolbox.

Note

The example below makes use of EchoArgs.exe - a small utility that simply echoes back arguments passed to it. Utility is part of the PowerShell Community Extensions, or the exe alone can be downloaded at https://ss64.com/ps/EchoArgs.exe.

Example

@hagatorn
hagatorn / WOL-pdq.ps1
Last active March 19, 2021 18:46
WOL with pdq utility
[cmdletbinding()]
param(
[Parameter(ParameterSetName=’NamedHost’)]
[string]$HostName,
[Parameter(ParameterSetName=’AllHosts’)]
[switch]$All,
[switch]$DHCP,
@JustinGrote
JustinGrote / RemoveSmallFolders.ps1
Created August 18, 2017 01:54
Remove Folders with less than a certain filesize in them. Works on Powershell Linux too with beta5
(get-childitem) | % {[PSCustomObject]@{Name=$_.Fullname;Size=(get-childitem $_ -recurse | % length | measure -sum | % sum | % {$_/1MB})}} | where size -lt 100 | % {Remove-Item -Recurse -Force $_.name}
@darkquasar
darkquasar / JEWebDav.ps1
Created February 15, 2018 03:49
Simple WebDav Server in Powershell
<#
Obtained from https://github.com/re4lity/subTee-gits-backups/blob/master/JEWebDav.ps1
#>
<#
.SYNOPSIS
Simple Reverse Shell over HTTP. Deliver the link to the target and wait for connectback.
Read And Write Files Over WebDAV Proof Of Concept
@JustinGrote
JustinGrote / Get-PRTGDeviceSysInfo.ps1
Created August 15, 2018 20:25
Function to retrieve PRTG Device System Information
#requires -module PrtgAPI -version 5
using namespace PrtgAPI
function Get-PRTGDeviceSysInfo {
<#
.SYNOPSIS
Retrieve PRTG Device System Information via the (undocumented) API.
.EXAMPLE
Get-PRTGDeviceSysInfo -ID 13926
<#PSScriptInfo
.VERSION 0.1.0
.GUID 05c41fde-bd40-4dd3-a72e-12ec14a50676
.AUTHOR Tyler Leonhardt
.COMPANYNAME Tyler Leonhardt
@steviecoaster
steviecoaster / Start-Deployment.ps1
Last active December 5, 2018 22:05
PDQ Deploy bootstrap script
Function Start-Deployment {
<#
.SYNOPSIS
Start a PDQ Deploy Deployment on a target machine
.DESCRIPTION
Trigger a PDQ Deploy deployment to start locally or on a remote machine with PDQ Deploy installed
.EXAMPLE
Start-Deployment -PackageName "Example Package" -Targets "Wolverine"
@AndrewPla
AndrewPla / Download-Latest_TOPdesk_Backup.ps1
Created January 28, 2019 14:01
Download the latest backup from TOPdesk using PowerShell.
# Credential needs to
$Credential = Get-Credential -Message 'enter TOPdesk operator credential with WebDAV permissions.'
$OutputFolder = 'C:\path\to\folder'
$tdurl = 'company.topdesk.net'
$psDriveParams = @{
PSProvider = 'FileSystem'
Root = "\\$tdUrl@SSL\webdav" # ex: '\\contoso.topdesk.net@SSL\webdav'
Credential = $Credential
Name = 'TOPdesk'