Skip to content

Instantly share code, notes, and snippets.

View ploegert's full-sized avatar
💭
¯\_(ツ)_/¯

Justin Ploegert ploegert

💭
¯\_(ツ)_/¯
View GitHub Profile
@ploegert
ploegert / write-log.ps1
Created February 3, 2016 18:58
write log for powershell
function Write-Log
{
param([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][AllowEmptyString()][string]$Message)
Write-Verbose -Verbose ("[{0:s}] {1}`r`n" -f (get-date), $Message)
}
@ploegert
ploegert / Configure-CapacityMetrics.ps1
Created January 27, 2016 17:50 — forked from RichardSlater/Configure-CapacityMetrics.ps1
Retrieve the latest storage capacity metrics for multiple storage accounts and display in a range of units.
# *************************************************************************************************
# * Configure-CapacityMetrics *
# *************************************************************************************************
# * Description: Configures Capacity metrics *
# * Author: Richard Slater <richard.slater@amido.co.uk> *
# * Date: 2013.02.02 *
# * Prerequisites: WAPPSCmdlets (https://www.windowsazure.com/en-us/manage/downloads/) *
# *************************************************************************************************
Set-StorageServicePropertiesForAnalytics -ServiceName "Blob" -StorageAccountName "<Storage Account Name>" -StorageAccountKey "<Storage Account Key>" -MetricsEnabled -MetricsRetentionPolicyDays 7 -MetricsRetentionPolicyEnabl
@ploegert
ploegert / Posh-Packagemgmt.ps1
Created January 26, 2016 16:12
Package Repos
#Reference Site:
#http://learn-powershell.net/2014/04/03/checking-out-oneget-in-powershell-v5/
#Show List of what commands are possible
get-command -module PackageManagement
<#
CommandType Name Version Source
@ploegert
ploegert / Connect-WinRM.ps1
Created January 25, 2016 15:45
Connect to remote host
function Write-Log
{
param([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][AllowEmptyString()][string]$Message)
Write-Verbose -Verbose ("[{0:s}] {1}`r`n" -f (get-date), $Message)
}
$destHost="10.9.13.21"
$user = "administrator"
$pass = ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force
@ploegert
ploegert / hubot_service.sh
Created January 8, 2016 17:13 — forked from mattsgarrison/hubot_service.sh
Start/Stop script to manage Hubot with Monit
#!/bin/zsh
### BEGIN INIT INFO
# Provides: hubot
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the hubot service
# Description: starts the Hubot bot for the Campfire rooms
@ploegert
ploegert / Create-WebConfigTransform.ps1
Created November 6, 2015 19:32 — forked from mpicker0/Create-WebConfigTransform.ps1
This PowerShell script runs a Web.config transformation. Visual Studio must be installed, and MSBuild.exe in your path. This is useful for one-off testing.
<#
.SYNOPSIS
Create a configuration transformation
.DESCRIPTION
This script runs an ASP.NET configuration transformation, given a source
configuration and transformation file. MSBuild.exe is assumed to be in
the path, and Visual Studio 2012 should be installed. Modify the path to
Microsoft.Web.Publishing.Tasks.dll if a different version of Visual Studio
is installed.
@ploegert
ploegert / Find-ARM_API_Version.ps1
Last active October 20, 2015 17:24
A way to find a listing of what arm templates are available for which resources... https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/
Switch-AzureMode AzureResourceManager
#Show all types
(Get-AzureProvider).ResourceTypes
#Get just the Compute Resource Types
((Get-AzureProvider) | Where-object { $_.ProviderNamespace -eq "Microsoft.Compute" }).resourceTypes
((Get-AzureProvider) | Where-object { $_.ProviderNamespace -eq "Microsoft.Network" }).resourceTypes
# Retrieve all available items
$allGalleryItems = Invoke-WebRequest -Uri "https://gallery.azure.com/Microsoft.Gallery/GalleryItems?api-version=2015-04-01&includePreview=true" | ConvertFrom-Json
# Get all items published by Microsoft
$allGalleryItems | Where-Object { $_.PublisherDisplayName -eq "Microsoft" }
# Get all gallery items with "SQL" in the description
$allGalleryItems | Where-Object { $_.Description -match "SQL" }
# Save default template for all items under directory "C:\Templates"
@ploegert
ploegert / Edit-XmlNodes.ps1
Created September 22, 2015 14:49
Use XPath to update XML using PowerShell Src: https://gist.github.com/jpoehls/2726969
function Edit-XmlNodes {
param (
[xml] $doc = $(throw "doc is a required parameter"),
[string] $xpath = $(throw "xpath is a required parameter"),
[string] $value = $(throw "value is a required parameter"),
[bool] $condition = $true
)
if ($condition -eq $true) {
$nodes = $doc.SelectNodes($xpath)
@ploegert
ploegert / Add-ToDomainWithDNS.ps1
Created August 5, 2015 20:04
Add DNS Server Add to Domain Reboot Server Add Groups
Get-DnsClientServerAddress
Set-DNSClientServerAddress -InterfaceAlias "Ethernet" –ServerAddresses ("DNS1","DNS2")
Get-DnsClientServerAddress
$domain = "DOMAIN"
$password = "PASSWORD" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\USER"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential