Skip to content

Instantly share code, notes, and snippets.

View pcgeek86's full-sized avatar
🍺
🥓

Trevor Sullivan pcgeek86

🍺
🥓
View GitHub Profile
@pcgeek86
pcgeek86 / gist:a52069044f2940c792eb
Created June 20, 2014 13:38
IseHg: Install Module via PowerShellGet
Install-Module -Name IseHg -Scope CurrentUser;
@pcgeek86
pcgeek86 / gist:3ea6936bb58956f9452e
Last active August 29, 2015 14:02
PowerShell Add-Member Examples
# Create a new object
$Person = [PSCustomObject]@{
FirstName = 'Nickolaj';
LastName = 'Andersen';
Age = 27
};
# Add a custom "type" name to the object called "Person"
$Person.pstypenames.Add('Person');
@pcgeek86
pcgeek86 / Import-IseHg.ps1
Created June 20, 2014 17:21
IseHg: Import Module
Import-Module -Name IseHg;
@pcgeek86
pcgeek86 / gist:d7c501fad6bd0f7333ae
Created July 1, 2014 00:41
PowerShell: Quickly review a list of files
# Author: Trevor Sullivan
# E-mail: [email protected]
# Website: http://trevorsullivan.net
# Description: This script allows you to quickly review the contents of a list of files
# in the folder specified in the $Path variable, using the "more" function.
$Path = 'C:\Users\ts\Documents\WindowsPowerShell\Modules\DSC\Resources';
$FileList = Get-ChildItem -Path $Path -Recurse | ? { !$_.PSIsContainer; };
$FileList | % {
Clear-Host;
$MyFilter = New-WmiEventFilter –Name WatchFolderRoboCopy –Query 'SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA "CIM_DirectoryContainsFile" AND TargetInstance.GroupComponent = "Win32_Directory.Name=\"c:\\\\FileHistory\""' –EventNamespace "root\cimv2"
$MyConsumer = New-WmiEventConsumer –ConsumerType CommandLine –Name WatchFolderRoboCopy –CommandLineTemplate "c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -<<<ParameterName1>>> %TargetInstance.<<<WmiPropertyName>>>%"
New-WmiFilterToConsumerBinding –Filter $MyFilter –Consumer $MyConsumer
@pcgeek86
pcgeek86 / DSC-NewAzureVM.ps1
Created September 10, 2014 15:25
Create Azure Virtual Machine with DSC Extension
#region Subscription
$SubscriptionName = 'Visual Studio Ultimate with MSDN';
Select-AzureSubscription -SubscriptionName $SubscriptionName;
#endregion
#region Affinity Group
$AffinityGroup = @{
Name = 'powershelldsc';
Location = 'North Central US';
};
@pcgeek86
pcgeek86 / DSC-DSCWave.ps1
Created September 10, 2014 15:29
PowerShell DSC Configuration to deploy the Microsoft DSC Resource Kit Wave 6
configuration DSCWave {
Archive DSCWave {
DependsOn = '[Script]DSCWave';
Ensure = 'Present';
Path = "$env:windir\temp\DSC Resource Kit Wave 6 08212014.zip";
Destination = "$env:ProgramFiles\WindowsPowerShell\Modules";
}
Script DSCWave {
GetScript = { @{ Result = (Test-Path -Path "$env:windir\temp\DSC Resource Kit Wave 6 08212014.zip"); } };
@pcgeek86
pcgeek86 / PPE2014Oct - Create Azure VM
Created October 30, 2014 18:25
PPE October 2014 - Create Microsoft Azure Virtual Machine
Add-AzureAccount;
$Username = '[email protected]';
$AzureCredential = Get-Credential -UserName $Username -Message 'Please enter your password';
Add-AzureAccount -Credential $AzureCredential;
$ModuleName = 'Azure';
Import-Module -Name $ModuleName;
@pcgeek86
pcgeek86 / Get-ParameterList.ps1
Created November 16, 2014 19:03
Document PowerShell Commands & Parameters
$ParameterList = @();
# Get a list of PowerShell commands
$CommandList = Get-Command -CommandType Cmdlet,Function -Module Azure;
foreach ($Command in $CommandList) {
foreach ($ParameterSet in $Command.ParameterSets) {
foreach ($Parameter in $ParameterSet.Parameters) {
$ParameterList += [PSCustomObject]@{
Module = $Command.ModuleName;
@pcgeek86
pcgeek86 / Create Azure Virtual Network High Performance Gateway.ps1
Created December 3, 2014 17:01
Create a Microsoft Azure virtual network high performance gateway
# Authenticate to Microsoft Azure and import subscription details
$Username = '[email protected]';
$GetCredential = @{
Username = $Username;
Message = 'Please enter your Microsoft Azure password.';
}
$AzureCredential = Get-Credential @GetCredential;
Add-AzureAccount -Credential $AzureCredential;
# Select the appropriate Microsoft Azure subscription