Skip to content

Instantly share code, notes, and snippets.

View pcgeek86's full-sized avatar
🍺
🥓

Trevor Sullivan pcgeek86

🍺
🥓
View GitHub Profile
@pcgeek86
pcgeek86 / Enter-AzurePSSession.ps1
Created January 8, 2015 19:33
A helper function to connect to Microsoft Azure virtual machines using PowerShell Remoting. Visit http://trevorsullivan.net.
function Enter-AzurePSSession {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceName,
[Parameter(Mandatory = $true)]
[string] $VMName
)
$SessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck;
$WinRMUri = Get-AzureWinRMUri -ServiceName $ServiceName -Name $VMName;
@pcgeek86
pcgeek86 / Stop-AzureVMParallel.ps1
Created February 27, 2015 19:28
Stop Microsoft Azure Virtual Machines in parallel
$VMList = Get-AzureVM;
foreach ($VM in $VMList) {
Start-Job -ScriptBlock {
Write-Output -Message ('Stopping VM {0} {1}' -f $args[0].ServiceName, $args[0].Name);
Stop-AzureVM -ServiceName $args[0].ServiceName -Name $args[0].Name -Force;
} -ArgumentList $VM;
}
@pcgeek86
pcgeek86 / azrdp.ps1
Last active August 29, 2015 14:17
A simple PowerShell function to simplify the process of establishing a RDP connection to a Microsoft Azure Virtual Machine.
function azrdp {
<#
.Author
Trevor Sullivan <pcgeek86@gmail.com>
.Description
Invoke a RDP session to an Azure Virtual Machine, without having to type the
Cloud Service name or Virtual Machine name.
.Outputs
@pcgeek86
pcgeek86 / Get-DscRequiredProperties.ps1
Created March 17, 2015 03:54
Find required properties for a PowerShell DSC Resource
### Find the required properties for a particular DSC resource
(Get-DscResource | Out-GridView -PassThru).Properties;
@pcgeek86
pcgeek86 / Azure Disks by Storage Account.ps1
Last active December 20, 2021 17:36
Azure Disk Objects :: Add a StorageAccount property
<#
Author: Trevor Sullivan
Date: 2015-03-29
Description: Microsoft Azure Disk objects offer the full URL to the cloud-based VHD
however, the Storage Account name is not exposed independently. We can
use PowerShell's Add-Member command to parse the URL and offer up the
Storage Account as its own property on each Disk object.
#>
Select-AzureSubscription -SubscriptionName 'Visual Studio Ultimate with MSDN';
@pcgeek86
pcgeek86 / Get-AzureStorageContainersAsync.ps1
Created April 3, 2015 02:32
This PowerShell script uses PowerShell Background Jobs to enumerate all blob containers in each of your Azure Storage Accounts.
<#
.Author
Trevor Sullivan <pcgeek86@gmail.com>
.Links
http://trevorsullivan.net
http://twitter.com/pcgeek86
.Description
This PowerShell script uses the Microsoft Azure PowerShell module along with PowerShell
@pcgeek86
pcgeek86 / Wait-AzureVMDscConfiguration.ps1
Created May 22, 2015 19:30
Waits for a DSC configuration to complete on an Azure Virtual Machine.
function Wait-AzureVMDscConfiguration {
<#
.Synopsis
Waits for a DSC configuration to complete on an Azure Virtual Machine.
.Parameter ServiceName
The name of the Azure Cloud Service containing the Virtual Machine.
.Parameter Name
The name of the Azure Virtual Machine inside the Cloud Service container.
@pcgeek86
pcgeek86 / PowerShell v5 Class Serialization Pattern.ps1
Created July 9, 2015 16:34
This Gist provides a suggested pattern for serializing / deserializing PowerShell v5 class instances
class Person {
[ValidateNotNullOrEmpty()]
[string] $FirstName;
[ValidateNotNullOrEmpty()]
[string] $LastName;
[string] $Address;
Person([string] $First, [string] $Last) {
$this.FirstName = $First;
@pcgeek86
pcgeek86 / gist:4a1b74f37eaecac58cf777820f0177c9
Created August 1, 2016 15:07
Trevor's PowerShell Prompt
function Prompt {
<#
.Notes
Author: Trevor Sullivan
Website: https://trevorsullivan.net
Twitter: https://twitter.com/pcgeek86
#>
$ATAT = @'
____==========_______
_--____ | | "" " "| \
@pcgeek86
pcgeek86 / ClusterHQ-FlockerHub-Demo.sh
Last active November 28, 2016 16:41
This Bash script is a simple end-to-end example of ClusterHQ Fli + FlockerHub.
#!/bin/bash
### Visit http://ui.dev.voluminous.io/user-tokens to get a user token
### NOTE: This file should contain a function definition called 'fli'
source ~/.bash-fli
set -e
shopt -s expand_aliases