Skip to content

Instantly share code, notes, and snippets.

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

Justin Ploegert ploegert

💭
¯\_(ツ)_/¯
View GitHub Profile
READING LOGS
Let us say that I wish to check in detail that everything went well on my VM. How would I do that? I can log in to my VM from Azure and check the local logs. The files of interest to us will be the following two locations on VM hard drive:
C:\Packages\Plugins\Microsoft.Powershell.DSC\1.0.0.0
C:\WindowsAzure\Logs\Plugins\Microsoft.Powershell.DSC\1.0.0.0
You may find that your VM has a newer version of Powershell DSC extension,in which case the version number at the end of the path might be slightly different.
#File: C:\examples\IISInstall.ps1
configuration IISInstall
{
node ("localhost")
{
WindowsFeature IIS
{
Ensure = "Present"
Name = "Web-Server"
@ploegert
ploegert / DSC-With-SecureCred.ps1
Created July 14, 2015 17:14
Passing Credentials to the Azure DSC Extension Handler Let's say we want to ensure that a virtual machine has a local user with certain credentials. We’ll create a new configuration, located in the file user_configuration.ps1: http://blogs.msdn.com/b/powershell/archive/2014/09/10/secure-credentials-in-the-azure-powershell-desired-state-configura…
<#
Let's say we want to ensure that a virtual machine has a local user with certain credentials.
We’ll create a new configuration, located in the file user_configuration.ps1:
#>
configuration Main
{
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[PSCredential]
@ploegert
ploegert / Export-VM.ps1
Created July 27, 2015 15:42
Export VM, including Stopping VM, Exporting it, and then Deleting VM instance
Add-AzureAccount
$SubName = "be-dev"
Set-AzureSubscription -SubscriptionName $SubName
Select-AzureSubscription -SubscriptionName $SubName
$workingDir = "P:\posh\config\BE-Dev\VMs"
$vmName = "eisdev-dc01"
$serviceName = "eisdev-dc"
@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
@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)
# 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 / 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
@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 / 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