Skip to content

Instantly share code, notes, and snippets.

@tjgruber
tjgruber / IronScripter-ScriptingChallengeMeetup.ps1
Created February 2, 2021 10:03
Iron Scripter - Scripting Challenge Meetup
$helpTopic = "about_Splatting"
$excludedWords = "the"
$words = ((Get-Help $helpTopic) -replace "[^\w]"," " -replace "\d"," " -replace '_'," " -split " ") | Where-Object {$_ -ne ""}
$sortedWords = $words | Group-Object | Sort-Object -Property Count -Descending | Where-Object -Property Name -NE $excludedWords
[PSCustomObject]@{
'Help Topic Name' = $helpTopic
'Word Count' = $words.Count
'Top Word' = ($sortedWords | Select-Object -First 1).Name
'Top Word Count' = ($sortedWords | Select-Object -First 1).Count
@tjgruber
tjgruber / Replace-LineInText.ps1
Last active April 5, 2020 11:37
Replace-LineInText PowerShell function to replace a specific line in a file
function Replace-LineInText {
[CmdletBinding()]
param (
[Parameter(Position=0)]
[string]$fileDirectory,
[Parameter(Position=1)]
[string]$fileExtension,
[Parameter(Position=2)]
[int]$lineNumber,
[Parameter(Position=3)]
az account list-locations | ConvertFrom-Json | FT displayName,name
param(
$Name = 'WEB1',
$Location = 'westeurope',
$ResourceGroup = 'WebServers'
)
New-AzResourceGroup -Name $ResourceGroup -Location $Location
$params = @{
Name = $Name
<html dir="ltr" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" gpmc_reportInitialized="false">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-16" />
<title>Windows 10 Security Settings</title>
<!-- Styles -->
<style type="text/css">
body { background-color:#FFFFFF; border:1px solid #666666; color:#000000; font-size:68%; font-family:MS Shell Dlg; margin:0,0,10px,0; word-break:normal; word-wrap:break-word; }
table { font-size:100%; table-layout:fixed; width:100%; }
//
lockPref("network.proxy.type", 5);
pref("general.config.obscure_value", 0); // only needed if you do not want to obscure the content with ROT-13
pref("general.config.filename", "mozilla.cfg");
@tjgruber
tjgruber / squid-manual-blacklist.acl
Created November 2, 2015 16:40
Squid Proxy server manual blacklist to use - Contains just one entry so it works when you turn the proxy on.
.facebook.com
@tjgruber
tjgruber / squid-whitelist.acl
Last active August 2, 2023 02:17
A squid proxy whitelist to get started. Allows all Office 365 and windows updates through proxy.
# PUT IN ALPHABETICAL ORDER
.aadrm.com
.activedirectory.windowsazure.com
.adhybridhealth.azure.com
.ajax.aspnetcdn.com
.ajax.googleapis.com
# .amazon.com
# .amazonaws.com
.appex.bing.com
.appex-rf.msn.com
@tjgruber
tjgruber / proxy.pac
Last active April 5, 2017 09:13
Used for deployment of Proxy
function FindProxyForURL(url, host) {
// If the hostname matches the domains below, send direct (bypass proxy).
if (dnsDomainIs(host, ".your.domain") ||
dnsDomainIs(host, ".domain1.com") ||
dnsDomainIs(host, ".domain2.com"))
return "DIRECT";
// If the protocol or URL matches, send direct.
// if (url.substring(0, 4)=="ftp:" ||