Skip to content

Instantly share code, notes, and snippets.

View PatrickJD's full-sized avatar
☁️
PowerShell + Lambda + CloudFormation

Patrick Duffy PatrickJD

☁️
PowerShell + Lambda + CloudFormation
View GitHub Profile
{
"IsEnabled": true,
"EngineConfiguration": {
"Components": [
{
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "SecurityEventLog",
"Parameters": {
"Levels": "7",
"LogName": "Security"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowListActions",
"Effect": "Allow",
"Action": [
"iam:ListVirtualMFADevices"
],
"Resource": "*"
function Get-STSTempCreds {
[CmdletBinding()]
param
(
[parameter(mandatory=$true, HelpMessage="Enter the MFA code from your MFA Device")]
[int]
$MFACode
)
# Get the current user's identity from CLI
Get-ADGroupMember -identity “CiscoVPNUsers” | select name | Export-csv -path C:\Reports\Groupmembers.csv -NoTypeInformation
@PatrickJD
PatrickJD / Function Logging
Created October 3, 2017 20:26
Found on Reddit PowerShell
$ErrorActionPreference = "Continue" # may be stop depending on your error handling
$RunDir = split-path -parent $MyInvocation.MyCommand.Definition # gets the current directory of the script
$Params = (Get-Content "$RunDir\config.json.txt") -join "`n" | ConvertFrom-Json # grabs my params
$d = Get-Date -Format yyyy-MM-dd_HHmm
$logfile = "$Logdir\$d-log.txt" # This will be your actual log file that gets retained with timestamp in the name
$Logdir = "$RunDir\Logs" # Sets logdir
$templog = "$Logdir\log.txt"
IF(Test-Path $LogDir -eq $false){ New-Item $Logdir -ItemType Directory} # If not logdir make one
Get-ChildItem "$Logdir" -Filter *log* | ?{$_.LastWriteTime -le (Get-Date).AddDays(-5)} | Remove-Item -Force -Confirm:$false # Clean up old logs