Skip to content

Instantly share code, notes, and snippets.

View billkindle's full-sized avatar
🏠
Works from home and likes it that way.

Bill Kindle billkindle

🏠
Works from home and likes it that way.
View GitHub Profile
function Get-NetAccountInfo {
#obtain the data and do some minor cleanup
$data = net.exe accounts
$data = $data -replace '^[T].*',''
foreach ($line in $data)
{
#split on double colon character
$line = $line -split '\:\s+'
@billkindle
billkindle / Get-DaysLeftPwshSummit.ps1
Last active April 17, 2018 03:02
Get-DaysLeftPwshSummit.ps1 function for PowerShell Profile or standalone use.
function Get-DaysLeftPwshSummit {
<#
Created By: Bill Kindle
Twitter: @BillKindle
Description:
This is just a simple function you can add to your PowerShell profile
as a reminder to register for PowerShell+DevOps Summit.
@billkindle
billkindle / Start-PresentationMode.ps1
Created April 23, 2018 22:08
Start a color blind friendly PowerShell console session.
function Start-PresentationMode {
# change certain colors to be friendlier to those with color blindness
Write-Host -ForegroundColor Yellow "Changing ERROR foreground color from RED >>> BLUE"
$Host.PrivateData.ErrorForegroundColor = "Blue"
Write-Host -ForegroundColor Yellow "Ghanging ERROR backround color >>> WHITE"
$Host.PrivateData.ErrorBackgroundColor = "white"
# Could add more here based on what colors are preferred but this is a start.
@billkindle
billkindle / Copy-FolderStructure.ps1
Created May 3, 2018 19:40
Simple way to copy a directory folder structure without copying contents of the folders.
<#
This script will only copy folder structure found in the $Source
path to the $Target path.
#>
# Adjust paths to suite needs
$Source = [path]
$Target = [path]
# This will only copy folders
@billkindle
billkindle / MultiHostServices.tests.ps1
Created February 25, 2019 14:29
Sample foreach loop using an array inside a Pester test to check a number of hosts that are running the same service in an application cluster.
# This is an exmaple of Infrastructure testing that can be done with Pester DSL and PowerShell
$nodes = @('node1','node2','node3','node4','node5')
Describe -Name 'Windows Appplication Service Infrastructure' -Tag 'Prod' {
Context -Name 'Application01 Service Checks' {
foreach ($node in $nodes) {
@billkindle
billkindle / Save-CommonModules.ps1
Last active December 11, 2020 04:54
A small script to get the latest PowerShell modules I regularly use.
# These are moudles that I need to routinely save from the PowerShell Gallery
$modules = @("Pester","dbatools","dbachecks","psTrustedHosts","PoshWSUS","PSWindowsUpdate","PSDecode","PoshRSJob","PSFramework",
"ScheduledJobTools","WindowsCompatibility","ImportExcel","BurntToast","Invoke-CommandAs","PoshEvents")
$path = Read-Host -Prompt 'Please enter the full path to which you want to save common modules:'
Foreach ($module in $modules) {
Save-Module -Name $module -Path $path
@billkindle
billkindle / Get-DnsPTR.ps1
Last active April 15, 2019 19:20
I had to find out if a PTR existed or not. First time I got to use DNS PowerShelll cmdlets and ran into some minor issues.....
<# This link helped me solve the error I was recieving:
https://powershell.org/forums/topic/get-dnsserverresourcerecord-fails-on-dns-server/
Big thanks to Logan B.!
#>
# Using a splatted array here, will make final cmd shorter!
$splat = @{
Name = 'hostname'
ComputerName = 'DNSserverName'
@billkindle
billkindle / Save-CommonModules.ps1
Last active December 11, 2020 04:54
I use this small script to occasionally update my most used modules so I can copy them to systems I manage or to a network share.
# These are moudles that I need to routinely save from the PowerShell Gallery
$modules = @("Pester","dbatools","dbachecks","psTrustedHosts","PoshWSUS","PSWindowsUpdate","PSDecode","PoshRSJob","PSFramework",
"ScheduledJobTools","WindowsCompatibility","ImportExcel","BurntToast","Invoke-CommandAs","PoshEvents","psbbix","UniversalDashboard.Community")
$path = Read-Host -Prompt 'Please enter the full path to which you want to save common modules:'
Foreach ($module in $modules) {
Save-Module -Name $module -Path $path -AcceptLicense -Force
@billkindle
billkindle / Get-LatestJRE.ps1
Created June 11, 2019 02:23
This script will download the latest Offline JRE installer for Windows x86 and x64.
<# Get-LatestJRE.ps1
Reference:
http://servertechs.info/automating-java-download-and-deployment-with-powershell-and-sccm/
#>
# First I need to obtain some Uri's from Oracle. I'll sort them out, grabbing only the Windows Offline links
$Links = $(Invoke-WebRequest 'http://www.java.com/en/download/manual.jsp' -UserAgent 'Mozilla/5.0 (Windows NT 6.1; wow64)').links |
Where-Object -Property innerHTML -like 'Windows Offline*' |
@billkindle
billkindle / Get-ExeStringOut.ps1
Created July 7, 2019 16:06
Capture string output from EXE
# Send STDOUT to a string variable so it can be parsed later in a script
# WIP - Not fully tested yet
$StrOutput = [string] (& myApp.exe 2>&1)