Skip to content

Instantly share code, notes, and snippets.

View JohnLBevan's full-sized avatar
🏠
Working from home

John Bevan JohnLBevan

🏠
Working from home
View GitHub Profile
@kgadek
kgadek / gist:e402a3edb18bd0e0682d
Created October 28, 2014 23:05
Powershell parallel
cls
"foo.txt", "bar.txt" | %{
$ScriptBlock = {
param($name)
Write-Host "[processing '$name' inside the job]"
Get-Content "$name" | %{
Write-Host "Content: $_"
}
Start-Sleep 1
@JohnLBevan
JohnLBevan / BoxStarter_AppServicesTeam.ps1
Last active August 29, 2015 14:16
This script should be used by all members of the Application Services team to ensure they have a common toolset ready to use (NB: also includes additional developer options which have been commented out / which will make up an advanced version later).
##Install Chocolatey
#iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
##Install BoxStarter
#choco install boxstarter
#
#Or simpler:
#http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/JohnLBevan/d79a6973509bf5bae425/raw/97b183bbba7946b8992e037e56f7bdb347a930be/BoxStarter_AppServicesTeam.txt
#ref: see https://github.com/mwrock/Chocolatey-Packages/blob/master/mwrock-TfsDesktop/tools/ChocolateyInstall.ps1 for a great example script
#https://gist.github.com/DavidBoike/11269706/4007b58e122dcb926cc7f0e4f134e51bfaebee78
@BrandtLassen
BrandtLassen / FixPerformanceCounters.sp1
Created May 23, 2014 11:05
Recreate BizTalk performance counters after in-place upgrade of BizTalk 2010 to BizTalk 2013
param([Switch]$Fix, [Switch]$Verbose)
<#
During our testing of in-place upgrades of BizTalk 2010 to BizTalk 2013 we've seen performance counters disappear (especially the BizTalk:Message Agent and BizTalk:Messaging counters).
Inspired by:
• http://blogs.msdn.com/b/biztalkperformance/archive/2007/09/30/how-to-manually-recreate-missing-biztalk-performance-counters.aspx
• http://blogs.msdn.com/b/biztalkcpr/archive/2010/06/23/have-you-manually-recreated-the-biztalk-performance-counter-using-the-following-link-but-some-of-the-counters-were-still-missing.aspx
@JohnLBevan
JohnLBevan / Copy-DirectoriesOnly.ps1
Created May 23, 2019 11:28
Robocopy command to copy entire directory structure without files
$source = '\\path\to\source'
$destination = '\\path\to\dest'
robocopy "$source" "$destination" /zb /e /xf *
<#
See https://ss64.com/nt/robocopy.html for notes
/zb - If you get access denied on a folder, try using backup mode to access it (see http://www.rainingforks.com/blog/2015/suggested-robocopy-switches-explained.html for detail)
/e - Copy subfolders (/s), including empty ones.
/xf * - exclude files matching a filename pattern; in this case any filename, so only copy directories
Note: dest will contain the child folders of source; not source itself.
@dungam
dungam / Dark Custom.xml
Created June 26, 2018 21:31
Programmer's Notepad - Customized Dark Theme
<UserSettings>
<override-colours caret="e6e6fa" indentGuides="282828" />
<override-classes>
<style-class name="default" font="Monaco" back="272828" fore="fafafa" />
<style-class back="222222" fore="666666" name="linenumbers"></style-class>
<style-class name="comment" fore="d500d5"/>
<style-class name="keyword" fore="f47a00" bold="true"/>
<style-class name="string" fore="5fff61" />
<style-class name="number" fore="fafafa" />
<style-class name="identifier" fore="fddf39" />
@victoroliv2
victoroliv2 / cross-site-xmlhttprequest.py
Created October 7, 2011 19:09
web.py server which allow cross-site xmlhttprequest
import web
urls = (
'/(.*)', 'Service'
)
app = web.application(urls, globals())
class Service:
def GET(self, name):
web.header('Access-Control-Allow-Origin', '*')
@zommarin
zommarin / Get-FileEncoding.ps1
Created December 15, 2011 12:43
Get-FileEncoding
function Get-FileEncoding($Path) {
$bytes = [byte[]](Get-Content $Path -Encoding byte -ReadCount 4 -TotalCount 4)
if(!$bytes) { return 'utf8' }
switch -regex ('{0:x2}{1:x2}{2:x2}{3:x2}' -f $bytes[0],$bytes[1],$bytes[2],$bytes[3]) {
'^efbbbf' { return 'utf8' }
'^2b2f76' { return 'utf7' }
'^fffe' { return 'unicode' }
'^feff' { return 'bigendianunicode' }
@sayedihashimi
sayedihashimi / show-console-colors.ps1
Last active May 29, 2021 17:07
PowerShell loop through console colors to display different results for foreground color & background color
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curForeground = $_
[enum]::getvalues([type]'ConsoleColor') | ForEach-Object{
$curBackground = $_
$msgStart= "Foreground={0}, Background={1}" -f $curForeground,$curBackground
$msgStart += (New-Object string -ArgumentList @(' ',(50-$msgStart.Length)))
$msgStart | Write-Host -NoNewline
@JohnLBevan
JohnLBevan / Get-LocalSecurityGroupInfo.ps1
Last active October 4, 2021 18:24
Get Local Security Group Info (PS2 compatible)
#based on code from this blog: https://mcpmag.com/articles/2015/06/18/reporting-on-local-groups.aspx
function Get-AdsiComputer {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string]$ComputerName = $env:COMPUTERNAME
)
process {
[ADSI]("WinNT://$ComputerName,computer")
@joefitzgerald
joefitzgerald / win-updates.ps1
Created December 31, 2013 23:18
Install All Windows Updates, Rebooting As Many Times As Required
param($global:RestartRequired=0,
$global:MoreUpdates=0,
$global:MaxCycles=10)
function Check-ContinueRestartOrEnd() {
$RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$RegistryEntry = "InstallWindowsUpdates"
switch ($global:RestartRequired) {
0 {
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry