Skip to content

Instantly share code, notes, and snippets.

Avatar
🍺
🥓

Trevor Sullivan pcgeek86

🍺
🥓
View GitHub Profile
@pcgeek86
pcgeek86 / gist:a52069044f2940c792eb
Created Jun 20, 2014
IseHg: Install Module via PowerShellGet
View gist:a52069044f2940c792eb
Install-Module -Name IseHg -Scope CurrentUser;
@pcgeek86
pcgeek86 / gist:3ea6936bb58956f9452e
Last active Aug 29, 2015
PowerShell Add-Member Examples
View gist:3ea6936bb58956f9452e
# 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 Jun 20, 2014
IseHg: Import Module
View Import-IseHg.ps1
Import-Module -Name IseHg;
@pcgeek86
pcgeek86 / gist:d7c501fad6bd0f7333ae
Created Jul 1, 2014
PowerShell: Quickly review a list of files
View gist:d7c501fad6bd0f7333ae
# Author: Trevor Sullivan
# E-mail: pcgeek86@gmail.com
# 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;
View gist:b5f29ab8a11b414b230f
$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 Sep 10, 2014
Create Azure Virtual Machine with DSC Extension
View DSC-NewAzureVM.ps1
#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 Sep 10, 2014
PowerShell DSC Configuration to deploy the Microsoft DSC Resource Kit Wave 6
View DSC-DSCWave.ps1
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 Oct 30, 2014
PPE October 2014 - Create Microsoft Azure Virtual Machine
View PPE2014Oct - Create Azure VM
Add-AzureAccount;
$Username = 'azureps@trevorsullivan.net';
$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 Nov 16, 2014
Document PowerShell Commands & Parameters
View Get-ParameterList.ps1
$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 Dec 3, 2014
Create a Microsoft Azure virtual network high performance gateway
View Create Azure Virtual Network High Performance Gateway.ps1
# Authenticate to Microsoft Azure and import subscription details
$Username = 'trevor@trevorsullivan.net';
$GetCredential = @{
Username = $Username;
Message = 'Please enter your Microsoft Azure password.';
}
$AzureCredential = Get-Credential @GetCredential;
Add-AzureAccount -Credential $AzureCredential;
# Select the appropriate Microsoft Azure subscription