Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
@mithunshanbhag
mithunshanbhag / arm-template-projects
Created October 25, 2019 02:00
ARM template projects
Some interesting github projects around ARM templates:
* https://github.com/Azure/azure-xplat-arm-tooling
* https://github.com/sam-cogan/arm-snippets-vscode
* https://github.com/benc-uk/armview-vscode
* https://github.com/microsoft/vscode-azurearmtools
* https://github.com/ChrisLGardner/ArmTemplateValidation
* https://github.com/CompositionalIT/farmer
* [possibly outdated] https://github.com/aumathew/AzureArmTemplateCompiler
# https://stackoverflow.com/questions/42145440/powershell-capture-mouse-click-event-inside-a-powershell-console
Add-Type -ReferencedAssemblies System.Drawing @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public class Window
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
@IISResetMe
IISResetMe / ConvertTo-Object.ps1
Last active July 25, 2023 23:12
Quick and dirty regex-based text-to-object parsing using named expressions groups and $Matches
function ConvertTo-Object {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[AllowEmptyString()]
[string[]]$InputString,
[Parameter(Mandatory=$true,ValueFromRemainingArguments=$true)]
[string[]]$Pattern
)
@mattifestation
mattifestation / wldp_interesting_rundll32_invocations.txt
Created May 30, 2018 22:23
DLLs and export functions that wldp.dll finds interesting when invoked with rundll32
StorageUsage.dll,GetStorageUsageInfo
acmigration.dll,ApplyMigrationShims
acproxy.DLL,PerformAutochkOperations
ppioobe.dll,setupcalendaraccountforuser
edgehtml.dll,#125
edgehtml.dll,#133
davclnt.dll,davsetcookie
appxdeploymentextensions.onecore.dll,shellrefresh
pla.dll,plahost
aeinv.dll,updatesoftwareinventory
@latkin
latkin / regexinfo.ps1
Last active April 1, 2022 01:43
Regex matching helper
<#
Dumps capture group locations and names/numbers
Example:
> regexinfo 'Jenny: 555-867-5309' '(?<name>\w+):\s+(?<phone>(?:(?<area>\d{3})-)?(\d{3}-\d{4}))'
[Jenny]: [[555]-[867-5309]]
| || |
| || 1
| |area
| phone
@Jaykul
Jaykul / ValidateUnique.md
Last active May 7, 2022 01:13
Validating PowerShell class properties

The simplest way to enforce rules on PowerShell class properties is to set the Type of the property, of course. But sometimes you want something a little bit more clever than that. One solution is to use a Validate* attribute, like ValidateRange or ValidateLength or ValidateSet attribute...

However, you can write your own, by just deriving from ValidateArguments() or something that derives from that, like the ValidateEnumeratedArguments class allows you to validate a whole array of items.

For instance, a simple validator would be one that validates uniqueness, based on a specific property. Our validator will be created fresh each time it's used, and then each item in the array will be passed through ValidateElement, so this works:

using namespace System.Collections.Generic
usin
@jdhitsolutions
jdhitsolutions / Get-PlanetPowerShellFeed.ps1
Created February 9, 2017 14:33
A PowerShell script to get the RSS feed from Planet PowerShell.
#requires -version 4.0
<#
get current entries in the PlanetPowerShell RSS feed
Because of the way entries are syndicated not every feed item
will parse cleanly or with information.
#>
[cmdletbinding()]
Param()
@Jaykul
Jaykul / Get-MsdnKeys.ps1
Last active August 3, 2022 20:28
PowerShell + Selenium Demo: Getting Started, and reusing cookies with Invoke-Request
# It might work in 4, but I'm not testing there. Lower you'll have to tweak code
#requires -Version 5.0
param(
# Your Live ID for MSDN login
[Parameter(Mandatory)]
[PSCredential]
[System.Management.Automation.CredentialAttribute()]
$Credential,
# Pick a browser to use. Defaults to Firefox (which doesn't seem to require an external Driver file)
#!/usr/bin/python
import os
# YouTube video searching API
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.tools import argparser
# Downloading YouTube videos
import pafy
@wgross
wgross / Enable-Ansi.ps1
Last active August 24, 2017 11:45
Get current weather from wttr.in in powershell. These scripts are based in the post at http://my-devnull.de/tag/wttr-in/.
# To enable ANSI sequences in a PowerShell console run the following commands.
# After that you can use wttr.in in you PowerShell just lake that:
# (curl http://wttr.in/ -UserAgent "curl" ).Content
#
# More on it:
# http://stknohg.hatenablog.jp/entry/2016/02/22/195644 (jp)
#
Add-Type -Namespace Win32 -Name NativeMethods -ErrorAction SilentlyContinue -MemberDefinition @"
[DllImport("kernel32.dll", SetLastError=true)]