Skip to content

Instantly share code, notes, and snippets.

const aws = require('aws-sdk');
const s3 = new aws.S3({ apiVersion: '2006-03-01' });
const readline = require('readline');
exports.handler = async (event, context, callback) => {
const bucket = event.Records[0].s3.bucket.name;
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
const params = {
Bucket: bucket,
Key: key,
@ismits
ismits / Invoke-SqlQuery.ps1
Created September 24, 2019 16:53
PowerShell run a TSQL query on a SQL Server instance and return the query results
<#
.Synopsis
Run the TSQL query on a SQL Server instance and return the query results. Use SELECT rather than PRINT to get output.
.Description
Run the TSQL query on a SQL Server instance and return the query results. Use SELECT rather than PRINT to get output.
#>
function Invoke-SqlQuery([string]$ComputerName = $Env:COMPUTERNAME,
[string]$InstanceName = "MSSQLSERVER",
[string]$Database = [System.String]::Empty,
@ismits
ismits / UpdateXml.ps1
Created September 24, 2019 16:49
Update Xml via PowerShell
function UpdateXml([string]$InputFile = $(Throw "Please provide a path to the input XML file in the InputFile parameter."),
[string]$OutputFile = $InputFile,
[string]$ParentXPath = $(Throw "Please provide an XPath expression to where you want to append/edit a child XML element in the ParentXPath parameter."),
[string]$ElementName = $(Throw "Please provide the name of the XML element to append/edit."),
[string]$ElementAttributeName,
[string]$ElementAttributeValue)
{
if (Test-Path -Path $InputFile)
{
Write-Log "Loading XML document from file: $InputFile"
@ismits
ismits / Configure-IISAppPoolMaxMemory.ps1
Created September 24, 2019 16:47
Configure IIS AppPool Max Memory via PowerShell
function Configure-IISAppPoolMaxMemory([string]$AppPoolName = "ApplicationPoolDefaults",
[int]$MaxMem = 20)
{
[int]$ExitCode = 0
# Ensure WebAdministration module is loaded.
if ((Get-Module -Name WebAdministration) -eq $null)
{
Write-Log "Importing module: WebAdministration"
Import-Module -Name WebAdministration -ErrorAction SilentlyContinue | Write-Log
@ismits
ismits / Configure-IE.ps1
Created September 24, 2019 16:43
Configure IE First Run and basic settings
function Configure-IE
{
Write-Log "Disabling IE first run customize prompts"
$RegPath = "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main"
New-RegKey $RegPath
Write-Log (New-ItemProperty -Path $RegPath -Name "DisableFirstRunCustomize" -Value 1 -PropertyType "DWORD" -Force)
$RegPath = "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Internet Explorer\Main"
New-RegKey $RegPath
Write-Log (New-ItemProperty -Path $RegPath -Name "DisableFirstRunCustomize" -Value 1 -PropertyType "DWORD" -Force)
@ismits
ismits / ClearIECookies.cmd
Created August 20, 2019 18:13
Command line to clear out IE cookies
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
@ismits
ismits / DisablingServicesOnServer2016wDE.ps1
Created August 15, 2019 16:30 — forked from hpaul-osi/DisablingServicesOnServer2016wDE.ps1
Disable unnecessary services that on Windows Server 2016 Desktop Experience (based on MS Security Blog recommendations)
# Disable extraneous services on Server 2016 Desktop Experience
# https://blogs.technet.microsoft.com/secguide/2017/05/29/guidance-on-disabling-system-services-on-windows-server-2016-with-desktop-experience/
Configuration DisablingServicesOnServer2016wDE
{
param(
[String]$ComputerName = "localhost",
[ValidateSet('ShouldBeDisabledOnly','ShouldBeDisabledAndDefaultOnly','OKToDisable','OKToDisablePrinter','OKToDisableDC')]
[String]$Level = 'OKToDisable'
)
@ismits
ismits / Disable-UAC.ps1
Created July 3, 2019 11:42
Disable UAC via PowerShell
function Disable-UAC
{
Write-Log "Disabling User Access Control (UAC)..."
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
New-RegKey $RegPath
Write-Log (New-ItemProperty -Path $RegPath -Name "EnableLUA" -Value 0 -PropertyType "DWORD" -Force)
Write-Log (New-ItemProperty -Path $RegPath -Name "ConsentPromptBehaviorAdmin" -Value 0 -PropertyType "DWORD" -Force)
Write-Log ("Disabling User Access Control (UAC) complete.")
return $true
}
@ismits
ismits / Get-AsyncResult
Created July 2, 2019 15:12
PowerShell function to wait for an async task to complete and return the result when completed
function Get-AsyncResult {
[CmdletBinding()]
[OutputType('Object')]
param (
[Parameter(Mandatory = $true, Position = 1)]
[object] $Task
)
Write-PSFMessage -Level Verbose -Message "Building the Task Waiter and start waiting." -Target $Task
$Task.GetAwaiter().GetResult()
@ismits
ismits / Oracle.psm1
Last active May 1, 2019 19:46
PowerShell module for Oracle DB
<#
.NOTES
Name: Oracle.psm1
Author: Immanuel Smits
Version History:
1.0 - 7/12/2016 - Initial Release.
.SYNOPSIS
Module to provide database access to PowerShell
.DESCRIPTION
Expanded description of what the script does.