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 boto3 | |
from datetime import datetime | |
import logging | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def lambda_handler(event, context): |
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
$ElasticSearchURL = 'https://<elasticsearchurl>:<port>' | |
$indices = (iwr "$ElasticSearchURL/_cat/indices?format=json&pretty").content | ConvertFrom-Json | |
$indices.Index | ?{$_ -match '\d{4}\.\d\d\.\d\d$'} | sort | |
$IndicesWithDate = $indices | ?{$_.index -like '*beat-*'} | select index,@{L="Date";E={get-date ($_.index -split '-')[1]}} | |
$indicesToDelete = $IndicesWithDate | ?{$_.date -lt (Get-Date).AddDays(-7)} | |
foreach($index in $indicesToDelete){ | |
$index.index | |
iwr "$ElasticSearchURL/$($index.index)" -Method delete |
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
from subprocess import check_output | |
from datadog import statsd | |
from datadog.api.constants import CheckStatus | |
import requests | |
import re | |
zpool_status = check_output(["/sbin/zpool", "status"]) | |
pattern = re.compile('state: ONLINE') |
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
$ProfileNames = @( | |
"Profile1", | |
"Profile2" | |
) | |
foreach($Profile in $ProfileNames){ | |
Set-AWSCredential -ProfileName $Profile | |
$StartTime = (Get-Date).AddDays(-30) | |
$EndTime = (Get-Date) |
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
$Env:AWSAccountID = "ACCOUNTID" | |
$Env:SourceRegion = "eu-central-1" | |
$ENV:DestinationRegion = "eu-west-1" | |
$env:AgeOfSnapshotsDays=1 | |
$SourceSnapshots = Get-EC2Snapshot -region $Env:SourceRegion -OwnerId $Env:AWSAccountID | |
$SourceFiltered = $SourceSnapshots | ?{$_.starttime -gt (get-date).AddDays(-1*$env:AgeOfSnapshotsDays)} | |
Write-Verbose "Found $($SourceFiltered.count) snapshots to copy from $Env:SourceRegion to $Env:DestinationRegion" |
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
Rename-Computer -NewName $newComputerName | |
Add-Computer -Credential $Credentials -DomainName 'SDLPRODUCTS.com' -Force -Options JoinWithNewName,AccountCreate |
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 Format-AnsiColor { | |
[CmdletBinding()] | |
[OutputType([String])] | |
param( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipeline = $true | |
)] | |
[AllowEmptyString()] | |
[String] |
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
$Ips = @("192.168.1.1") | |
foreach($Region in $(Get-AWSRegion).Region){ | |
$SecurityGroupsContainingRDP = Get-EC2SecurityGroup -region $Region| ?{$_.ippermission.FromPort -eq 3389} | |
Foreach($SecurityGroup in $SecurityGroupsContainingRDP){ | |
Write-Verbose "Adding WinRM to $($SecurityGroup.GroupID)" | |
try{ | |
Grant-EC2SecurityGroupIngress -GroupId $SecurityGroup.GroupId -region $Region -IpPermission @{IpProtocol="TCP";FromPort=5985;ToPort=5986;IPRanges=$IPs} | |
}catch{ | |
if($_.exception.message -like "*already exists*"){ | |
Write-Verbose "`tRule already exists" |
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
$BuildDirs = gci "W:\Jenkins\jobs\" -recurse -filter builds | ?{$_.psiscontainer} | |
$BuildDirs | %{ | |
$Builds = $_ | gci | select *,@{L="NameInt";e={[int]$_.name}} | ?{$_.nameint}| sort nameint -Descending | |
if($builds.Length -gt 30){ | |
$Builds[30..$($builds.length-1)].fullname | Remove-Item -Force -Recurse -verbose | |
}else{ | |
$Builds.Length | |
} | |
} |
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
from subprocess import check_output | |
from datadog import statsd | |
from datadog.api.constants import CheckStatus | |
import re | |
zpool_status = check_output(["/sbin/zpool", "status"]) | |
pattern = re.compile('state: ONLINE') | |
if pattern.search(zpool_status) : |