Skip to content

Instantly share code, notes, and snippets.

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

Justin Ploegert ploegert

💭
¯\_(ツ)_/¯
View GitHub Profile
@ploegert
ploegert / Azure- Connect Subscription.ps1
Last active August 29, 2015 13:57
POSH, Azure - Connect To Subscription
#Import-AzurePublishSettingsFile $PubFile
$AzureSubName = "be-prod"
$AzureSubName = "be-dev"
$AzureSubName = "be-uat"
Set-AzureSubscription -SubscriptionName $AzureSubName
Select-AzureSubscription -SubscriptionName $AzureSubName
$CurrentSub = (Get-AzureSubscription | where-object { $_.IsCurrent -eq $true }).SubscriptionName
write-host "Current SubscriptionName: $CurrentSub" -foregroundcolor green
#==============================================================================
# SEND EMAILS Helper
#==============================================================================
function SendEmailAlert()
{
PROCESS
{
write-host "`nSending Email to Notification List with subject of: $EmailSubject`n" -foregroundcolor yellow
@ploegert
ploegert / POSH - Log to System Event Log
Created March 31, 2014 18:33
POSH - Log to System Event Log
#==============================================================================
# Log System Event Log
#==============================================================================
function LogSystemEventLog()
{
param ([string]$eventid = "0001", [string]$eventsource = "adapter", [string]$eventmessage = "Default Message", [string]$loglevel = "Info")
PROCESS
{
switch ($loglevel)
{
@ploegert
ploegert / POSH - Search XML Object for non-empty value
Created April 17, 2014 19:36
POSH - Search XML Object for non-empty value
function get-XMLObjectChild ([xml] $envXml)
{
# try
#{
$h=@{}
#$envXml.Environment.deploy.PSRemote.GetEnumerator() | %{$h[$_.name]=$_.value }
$envXml1 = $envXml.SelectNodes("Environment/deploy/PSRemote")
$envXml1
$envXml1.GetEnumerator() | %{$h[$_.name]=$_.value }
@ploegert
ploegert / Posh-StatusUpdate
Created May 9, 2014 20:17
Posh-Write status update
for ($i = 1; $i -le 100; $i++ )
{write-progress -activity "Search in Progress" -status "$i% Complete:" -percentcomplete $i;}
@ploegert
ploegert / Setup-Log4Posh.ps1
Created June 17, 2014 14:44
Setup Log4Net/Log4Posh
Write-Verbose -Verbose:$ShowVerbose "BEGIN: log4net configuration definition"
$log = New-Log4Posh -Configuration "C:\Program Files\WindowsPowerShell\Modules\poshcat\log4posh\log4net.config" -Dll "C:\Program Files\WindowsPowerShell\Modules\poshcat\log4posh\log4net.dll" -Verbose:$ShowVerbose
$location = [System.Net.Dns]::GetHostName()
[log4net.NDC]::Push($location);
$location = Split-Path (Split-Path $myInvocation.MyCommand.path) -Leaf
[log4net.NDC]::Push($location);
$Log = [log4net.LogManager]::GetLogger($Host.GetType())
Write-Verbose -Verbose:$ShowVerbose "END: log4net configuration definition"
@ploegert
ploegert / PSRemote-CopyFiles.ps1
Created June 18, 2014 20:26
PSRemote-CopyFiles
#Get the Remote URL
$uri = Get-AzureWinRMUri -ServiceName $AzureServiceName -Name $AzVM
srvuser = "DOMAIN\USER"
$srvpass = "Password"
#create the credential for the remote service
$log.debug("Creating credential for the Remote Session..")
$passwordCred = ConvertTo-SecureString -AsPlainText $srvpass -Force
$credentials = New-Object System.Management.Automation.PSCredential ($srvuser, $passwordCred)
@ploegert
ploegert / SQLAzure-CreateUserandAddRoles.sql
Last active August 29, 2015 14:03
SQL Azure Create User and Add Permissions
CREATE LOGIN TableauReader WITH password='1231!#ASDF!a';
CREATE USER TableauReader FROM LOGIN TableauReader;
CREATE ROLE db_execute
GRANT EXECUTE TO db_execute
exec sp_addrolemember 'db_execute', 'TableauReader'
EXEC sp_addrolemember 'db_ddladmin', 'TableauReader';
EXEC sp_addrolemember 'db_datareader', 'TableauReader';
@ploegert
ploegert / Deploy-WebSite.ps1
Created February 20, 2015 20:09 — forked from mmooney/deploy.ps1
Example of how to deploy an azure web site and change Hosting Plan
#Modified and simplified version of https://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/
#From: #https://gist.github.com/3694398
$subscription = "[SubscriptionName]" #this the name from your .publishsettings file
$service = "[ServiceName]" #this is the name of the cloud service
$storageAccount = "[StorageAccountName]" #this is the name of the storage service
$slot = "production" #staging or production
$package = "[Fully Qualified Path to .cspkg]"
$configuration = "[Fully Qualified path to .cscfg]"
$publishSettingsFile = "[Path to .publishsettings file, relative is OK]"
$timeStampFormat = "g"
@ploegert
ploegert / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console