$parms = @{
Path = "C:\windows\system32"
Recurse = $true
ErrorAction = "SilentlyContinue"
}
Measure-Benchmark -RepeatCount 25 -Technique @{
ForEachObject = {
Get-ChildItem @parms | ForEach-Object -Process {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tweet function from https://gallery.technet.microsoft.com/Send-Tweets-via-a-72b97964 | |
workflow Send-Tweet { | |
param ( | |
[Parameter(Mandatory=$true)][string]$Message | |
) | |
InlineScript { | |
[Reflection.Assembly]::LoadWithPartialName("System.Security") | |
[Reflection.Assembly]::LoadWithPartialName("System.Net") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
break | |
<# | |
01. Find instances | |
02. Connect to instances | |
03. Check backups | |
04. Check disk space | |
05. Perform backups | |
06. Check for corruption | |
07. Install maintenance scripts | |
08. Export all settings for DR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install required packages (ntp keeps your clock on time) | |
apt-get -y install ntp ntpdate | |
# To add your DC to the time server list, edit /etc/ntp.conf | |
service ntp stop | |
ntpdate -s ntp.ubuntu.org | |
service ntp start | |
# install required packages | |
apt-get -y install krb5-user samba apache2 libapache2-mod-auth-kerb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: github pages | |
on: | |
push: | |
branches: | |
- blog # Set a branch to deploy | |
pull_request: | |
jobs: | |
deploy: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# No longer used but didn't want to throw it away. | |
function Invoke-WsusDbQuery { | |
[CmdletBinding()] | |
param ( | |
[string]$ComputerName = $script:WsusServer, | |
[PSCredential]$Credential = $script:WsusServerCredential, | |
[string]$Pattern, | |
[string]$UpdateId, | |
[switch]$EnableException | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$MyScript = [powershell]::Create() | |
$null = $MyScript.AddScript( { Import-Module -Name Terminal-Icons } ) | |
$Runspace = [runspacefactory]::CreateRunspace() | |
$MyScript.Runspace = $Runspace | |
$null = Register-ObjectEvent -InputObject $MyScript -EventName InvocationStateChanged -Action { | |
Import-Module -Name Terminal-Icons | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Fans of (Linux/UNIX) GNU findutils' locate will appreciate Invoke-Locate, which provides similar functionality. "locate" and "updatedb" aliases are automatically created. | |
.DESCRIPTION | |
This script was made in the spirit of GNU locate. While the name of this script is Invoke-Locate, it actually creates two persistent aliases: locate and updatedb. A fresh index is automatically created every 6 hours, updatedb can be used force a refresh. Indexes generally takes less than three minutes. Performing the actual locate takes about 300 milliseconds. Invoke-Locate supports both case-sensitive, and case-insensitive searches, and is case-insensitive by default. | |
locate queries a user-specific SQLite database prepared by updatedb (Task Scheduler) and writes file names matching the pattern to standard output, one per line. Since the back-end is SQL, SQL "LIKE" syntax can be used for the search pattern (ie % and _). Asterisks are automatically translated to % for people who are used to searching with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Logger { | |
$dll = Join-Path -Path $script:ModuleRoot -ChildPath log4net.dll | |
$null = Add-Type -Path $dll | |
$pattern = '[%date{yyyy-MM-dd HH:mm:ss}] [%level] [%message]%n' | |
$layout = [log4net.Layout.ILayout](New-Object log4net.Layout.PatternLayout($Pattern)) | |
$dir = "C:\temp" # this is actually in my json config file | |
$dir = Join-Path -Path $dir -ChildPath logs | |
if (-not (Test-Path -Path $dir)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-FileHash { | |
<# | |
.Synopsis | |
This is a simple file hash comparison tool that writes to Windows Events when changes are detected | |
.Description | |
This is a simple file hash comparison tool that writes to Windows Events when changes are detected | |
.PARAMETER FilePath | |
The path to the file to hash and compare |