Skip to content

Instantly share code, notes, and snippets.

View lazywinadmin's full-sized avatar

François-Xavier Cat lazywinadmin

View GitHub Profile
@dfinke
dfinke / CFSBuddy.ps1
Created September 17, 2014 14:37
PowerShell v5.0 ConvertFrom-String Buddy - A GUI that helps you work with this new powerful cmdlet
#Requires -Version 5.0.9814.0
if(!($PSVersionTable.PSVersion.Major -ge 5 -and $PSVersionTable.PSVersion.Build -ge 9814)) {
"Sorry you need PSVersion 5.0.9814.0 or newer"
$psversiontable
return
}
Add-Type -AssemblyName presentationframework
@onpaws
onpaws / list_perms.sql
Last active June 15, 2023 18:41
list permissions SQL Server
/* via http://stackoverflow.com/questions/7048839/sql-server-query-to-find-all-permissions-access-for-all-users-in-a-database
Security Audit Report
1) List all access provisioned to a sql user or windows user/group directly
2) List all access provisioned to a sql user or windows user/group through a database or application role
3) List all access provisioned to the public role
Columns Returned:
UserName : SQL or Windows/Active Directory user cccount. This could also be an Active Directory group.
UserType : Value will be either 'SQL User' or 'Windows User'. This reflects the type of user defined for the
SQL Server user account.
@gscales
gscales / gist:26d9fa299b3de5f86a15
Created May 1, 2015 00:13
Powershell Online Calendar sample
Invoke-RestMethod -Uri ("https://outlook.office365.com/api/v1.0/users/[email protected]/calendarview?startDateTime=" + (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ") + "&endDateTime=" + (Get-Date).ToUniversalTime().AddDays(7).ToString("yyyy-MM-ddThh:mm:ssZ")) -Credential (Get-Credential) | foreach-object{$_.Value}
@altrive
altrive / ToastNotification_Windows10.ps1
Last active May 12, 2024 09:34
Windows 10 toast notification sample
$ErrorActionPreference = "Stop"
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipuration
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null
@altrive
altrive / PSv5_Preview_Features.md
Last active April 24, 2016 16:45
PowerShell v5 Undocumented Features List
Note: Following features are tested on Windows 10 Preview Build 10074 environment

PSReadLine

Windows 10 Preview contains PSReadLine module at "%ProgramFiles%\WindowsPowerShell\Modules" (WMF 5.0 Preview don't contain this modules)

PSReadLine is automatically loaded when PSConsoleHost launched(if available). This feature can be controlled by following command.

@ellisgeek
ellisgeek / Elevate.ps1
Last active October 7, 2024 00:54
Automatically relaunch Powershell script as Administrator
#region Elevate
function Elevate {
<#
.SYNOPSIS
Automatically (re)launch Powershell script as Administrator including parameters
.PARAMETER ScriptPath
Path to the script that should be launched. Defaults to the current script
.PARAMETER Parameters
A Hashtable of parameters that should be passed to the elevated script, where the "key" is the
parameter name and the "value" is the parameter value
@dfinke
dfinke / Get-Snoverism.ps1
Created December 8, 2015 20:06
Wisdom form the Shellfather, Jeffrey Snover - via Don Jones
function Get-Snoverism {
(Invoke-WebRequest http://snoverisms.com/).images.src |
Where {$_ -match 'quotes'} |
Get-Random |
Where { start "http://snoverisms.com/$($_)" }
}
@mattifestation
mattifestation / WMI_attack_detection.ps1
Last active March 16, 2021 23:02
BlueHat 2016 - WMI attack detection demo
#region Scriptblocks that will execute upon alert trigger
$LateralMovementDetected = {
$Event = $EventArgs.NewEvent
$EventTime = [DateTime]::FromFileTime($Event.TIME_CREATED)
$MethodName = $Event.MethodName
$Namespace = $Event.Namespace
$Object = $Event.ObjectPath
$User = $Event.User
@dfinke
dfinke / GetCoolFace.ps1
Last active July 15, 2024 06:19
ᕙ༼ຈل͜ຈ༽ᕗ Get a cool ascii face
# From:
# https://github.com/maxogden/cool-ascii-faces
function Get-CoolFace {
param(
$Count=1
,[Switch]$All
)
$faces = "( .-. )",
@dfinke
dfinke / Get-PSGalleryInfo.ps1
Created January 29, 2016 19:11
Get statistics for published PowerShell Gallery packages
function Get-PSGalleryInfo {
param(
[Parameter(ValueFromPipelineByPropertyName=$true)]
$Name
)
Begin {
$t = @"
{Name*:PowerShellISE-preview} {[version]Version:5.1.0.1} (this version) {[double]Downloads:885} {[DateTime]PublishDate:Wednesday, January 27 2016}
{Name*:ImportExcel} 1.97 {Downloads:106} Monday, January 18 2016
"@