Skip to content

Instantly share code, notes, and snippets.

param(
$Computer ='dc01.contoso.com',
$Minutes = -240
)
if ($Minutes -ge 0) {$Minutes = 0 - $Minutes}
$SelectOuput = @(
@{n='ComputerName';e={$_.MachineName}},
@{n='Time';e={$_.TimeCreated}},
@srpomeroy
srpomeroy / Get-AllStorageAccountTotals.ps1
Last active October 29, 2016 02:24
Enumerates through all storage accounts in an Azure Resource Manage subscription and returns the total number of Storage Accounts, Containers and Blobs as well as the total time to execute.
$subsciptionId = "<Azure Subscription ID>"
Select-AzureRmSubscription -SubscriptionId $subsciptionId
$startTime = Get-Date
$storageAccounts = Get-AzureRmStorageAccount
$totalStorageAccounts = $($storageAccounts.Count)
$totalContainers = $null
$totalBlobs = $null
#PowerShell
#This script will allow you to remotely enable RDP via PowerShell Remoting
$Server = Read-Host -Prompt "Name of server:"
Invoke-Command -ComputerName $Server -Credential (Get-Credential) -ScriptBlock {
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1
Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True }
@srpomeroy
srpomeroy / Get-RightScaleSystemStatus.ps1
Created November 29, 2016 18:24
PowerShell example of retrieving RightScale system status
$headers = @{"accept"="application/json"}
$statusPageContent = Invoke-WebRequest -Uri "http://status.rightscale.com" -Headers $headers
$components = ($statusPageContent | ConvertFrom-Json).components
$componentObject = @()
foreach ($component in $components) {
$componentObject += [pscustomobject]@{
"name" = $component.name
"status" = $component.status
}
@srpomeroy
srpomeroy / GetRightScaleAPIStatus.sh
Last active November 29, 2016 18:54
CURL/JQ example of retrieving RightScale API Status
curl -sS -H "accept: application/json" http://status.rightscale.com | jq '.components[] | select(.name == "Cloud Management API 1.5") | .status'
@srpomeroy
srpomeroy / GetRightScaleAPIStatus.ps1
Created November 29, 2016 18:58
PowerShell example of retrieving RightScale API Status
((Invoke-WebRequest -Uri "http://status.rightscale.com" -Headers @{"accept"="application/json"} | ConvertFrom-Json).components | Where-Object {$_.name -eq "Cloud Management API 1.5"}).status
@srpomeroy
srpomeroy / RightScale - Schedule Snapshot.ps1
Created February 24, 2017 04:16
RightScale/Rightlink10/RSC Use PowerShell Job to schedule a snapshot by running a script in RightScale via RSC.
$errorActionPreference = "stop"
$scriptId = "12345678"
$rsc = 'C:\Program Files\RightScale\RightLink\rsc.exe'
$snapshot_Name = $ENV:SNAPSHOT_NAME
$snapshot_Save = $ENV:KEEP_SNAPSHOTS
$scheduledTask_Time =$ENV:SCHEDULED_TASK_TIME
$scheduledTask_Name = "RightScale Snapshot - $ENV:SNAPSHOT_NAME"
if(($ENV:ENABLE_SNAPSHOT -eq $true) -and (!($ENV:KEEP_SNAPSHOTS) -or !($ENV:SCHEDULED_TASK_TIME))) {
Write-Output "Error! Must provide value for KEEP_SNAPSHOTS and SCHEDULED_TASK_TIME!"
@srpomeroy
srpomeroy / RightScale - Call Additional Script on Terminate.ps1
Created February 24, 2017 04:18
RightScale/Rightlink10/RSC Call additional script on terminate
$erroractionpreference = "Stop"
$rightlink_dir = 'C:\Program Files\RightScale\RightLink'
$decom_reason = & "${rightlink_dir}\rsc.exe" rl10 show /rll/proc/shutdown_kind
$rightScriptID = "123456789"
If ($decom_reason -eq "terminate") {
Write-Output "Instance is terminating. Running script..."
#Run RightScript
@srpomeroy
srpomeroy / Remove-BCDTimeout.ps1
Created December 21, 2017 19:19
Remove default OS timeout in Windows
$bcdConfig = & bcdedit.exe /enum
foreach($line in $bcdConfig) {
if ($line -like "timeout*") {
$timeout = $line.replace('timeout','').replace(' ','')
if($timeout -ne 0) {
Write-Output "Changing timeout from $timeout to 0"
& bcdedit.exe /timeout 0
BREAK
}
@srpomeroy
srpomeroy / Get-MSNESeasonData.ps1
Last active February 7, 2018 05:50
PowerShell script to parse MSNE event data
# Based on 2017 results: http://www.motorsportsne.com/
$urls = 'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2003%2026%20a-x_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2004%2002%20a-x_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2004%2030%20a-x%20removed%20a1%20a4%20no%20work_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2006%2004%20a-x_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2007%2028%20a-x_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2008%2006%20A-X_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2008%2018%20a-x_fin.htm',
'https://axwaresystems.com/axorm/files/MotorSportsNE/2017%2008%2020%20a-x_fin.htm',