This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#h/t: http://tfl09.blogspot.com/2008/07/finding-your-external-ip-address-with.html | |
function getCurrentExternalIPAddress() { | |
$wc=New-Object net.webclient | |
$wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$resourceGroupName = "TESTSERVERS" | |
$location = "West US" | |
$storageType = "Standard_GRS" | |
function createStorageAccount($storageAccountPrefix) { | |
$storageAccountCreated = $False | |
#storage account names need to be globally unique | |
#loop until we find a storage account name that works | |
while ($storageAccountCreated -eq $False) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkADGroup($adLDAPHost, $ldap_dn, $queryUser, $queryPassword, $user, $group) { | |
// Connect to AD | |
$ldap = ldap_connect($adLDAPHost) or die("Could not connect to LDAP"); | |
ldap_bind($ldap,$queryUser,$queryPassword) or die("Could not bind to LDAP"); | |
// Search AD | |
$results = ldap_search($ldap,$ldap_dn,"(samaccountname=$user)",array("memberof","primarygroupid")); | |
$entries = ldap_get_entries($ldap, $results); | |
// No information found, bad user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module AWSPowerShell | |
#get a date 90 days ago to use to calculate old credentials | |
$date90DaysAgo = (Get-Date).AddDays(-90) | |
#gather all of our iam users | |
$users = Get-IAMUsers | |
#iterate each of my uesrs | |
foreach ($u in $users) { | |
#grab all the keys for a user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module AWSPowerShell | |
Set-AWSCredentials -AccessKey myAccessKey -SecretKey mySecretKey -StoreAs myCredentialName | |
Initialize-AWSDefaults -ProfileName myCredentialName -Region us-west-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the CPU Steal Time value from VMWare | |
$stolenProperty = Get-CimInstance Win32_PerfRawData_vmGuestLib_VCPU -Property CpuStolenMs | Select-Object -Property CpuStolenMs | |
Write-Host $stolenProperty.CpuStolenMs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Install-WMF5 ($WMF5location, $server) { | |
Invoke-Command -ComputerName $server -ScriptBlock { New-Item c:\temp\WMF5 -Type Directory -Force -ErrorAction 'SilentlyContinue' | Out-Null } | |
$serverTempLocation = "\\$($server)\c`$\Temp\WMF5\" | |
#copy the wmf5 file from a central location to our server at c:\temp\wmf5 | |
Copy-Item $WMF5location $serverTempLocation | |
#use wusa to extract the cab file to install the wmf5 package | |
$scriptBlock = { Start-Process -FilePath 'wusa.exe' -ArgumentList "c:\temp\WMF5\Win8.1AndW2K12R2-KB3134758-x64.msu /extract:C:\temp\WMF5\" -verb runAs -Wait -PassThru } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I spent many hours today trying to grok Handlers in Chef, and get a functional email handler in place. | |
#This is a brain dump of my configuration in the hopes that others find it useful (and to remind myself). | |
#cd to your repo's cookbooks directory, download the chef_handler cookbook, and un-tarzip | |
knife cookbook site download chef_handler | |
tar -xvzf chef_handler.tgz | |
#create a send_email.rb handler in your default chef_hander handler directory with the below results | |
#replace EMAILADDRESS, DOMAIN, EMAILSERVER with values for your environment | |
vi ~/repo/cookbooks/chef_handler/files/default/handlers/send_email.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#BACKSTORY: | |
#I wanted to get a way to quickly and centrally see how my Chef runs might be going. | |
#SUMMARY: | |
#1. I built a quick web service in PHP (details not pertinent here), that takes parameters node, status, and runlist, and saves the results to a database for reporting purposes | |
#2. I configured Chef to call my PHP web service on each successful and failed chef-client run using Chef.event_handler in my default.rb | |
#created a helper.rb at ~/POP/cookbooks/MyCookbook/libraries/helper.rb | |
###################################################################### | |
require 'net/http' |
OlderNewer