Month: March 2019

SQL Failover (Simple Method)

$servers="SQL01","SQL02","SQL03"; # Dynamic Credential method 1 $who = whoami if ($who.substring($who.length-2, 2) -eq "-admin"){$username=$who;} else…

Remediate IE Vulnerabilities

<# PowerShell Script to Secure Internet Explorer & Memory Operations reg add "HKLM\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" /v…

PowerShell: Passing Local Functions to Remote WinRM Sessions

# Dynamic Credential Method 1 $who = whoami if ($who.substring($who.length-2, 2) -eq "-a"){$username=$who;} else {$username=$who+"-admin";}…

List Folder Sizes

# Powershell Script to list folders sizes Install-Module PSFolderSize $folders = "\\FILESERVER01\SHARE01","C:\Windows\Users\kimconnect" foreach ($folder in…

List Autorun Services

# $cred = get-Credential -credential kdoan-a $Username = 'kimconnect\kim-Admin $Password = 'PASSWORD' $pass = ConvertTo-SecureString…

Last Logon Dates of List of AD Accounts

import-module activedirectory$output=""Get-Content C:\Users\kimconnect\Desktop\targetAccounts.txt | Foreach-Object -Process{ #  cast an array object as string before using…

Find Empty Directories

$directories="\\FILESERVER01\SHARE01" # Dynamic Credential method 1 $who = whoami if ($who.substring($who.length-2, 2) -eq "-admin"){$username=$who;} else…

SQL AlwayOn High Availability Default Port

Internal SQL DEV & QA environments may have SQL listening to the default port of…

PowerShell: Elevating Credential

$jumpbox="127.0.0.1" <# # Static Credentials (unsecured) $username = (Get-ADDomain).name+"\ADMINISTRATOR" $password = "PASSWORD" #> # Dynamic…

PowerShell: Disable NetBios

# Set Credentials $username = "KIMCONNECT\"+(Read-Host -Prompt 'Input the Admin Username: ') $password = Read-Host…

PowerShell: Convert String to Command

# Method 1 $command =@"ping google.com"@$scriptBlock = [Scriptblock]::Create($command)Invoke-Command -ComputerName localhost -ScriptBlock $scriptBlock# Method 2$xVariable="K1"$yVariable="ping"$commandString=$yVariable+" "+$xVariablefunction…

Check Whether an Entity Has Access to a Directory or Its Children

Write-Host "This script just be ran in the context of a File Server Administrators member"…

Check Servers NSLookup of a Listener to Match Active Node IP

$servers="SQL01","SQL02","SQL03","SQL04" $listener="halistener01" $activeNode="10.10.10.5" # Dynamic Credential method 1 $who = whoami if ($who.Substring($who.length-2, 2)="-admin"){$username=$who;} else…

Check a List of Servers to Find Currently Stopped Autorun Services

$username = (Get-ADDomain).name+'\USERNAME' $Password = 'PASSWORD' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $cred = New-Object…

Add a Domain Group to Local Administrators Group

$checkGroup="Administrators" $addMember="KIMCONNECT\Desktop Admins" # Dynamic Credential $who = whoami if ($who.substring($who.length-2, 2) -eq "-admin"){$username=$who;} else…

Add Local Windows User

# Dynamic Credential$who = whoamiif ($who.substring($who.length-2, 2) -eq "-admin"){$username=$who;}else {$username=$who+"-admin";}$password = Read-Host -Prompt "Input the…

SonicWall Port Forwarding

Quick How-To Configuration of SonicWall Many to One NAT Set Up Services Network > Services…

WinRM Management Consideration

Infrastructure needs to be able to leverage scripting automation to perform Vulnerability Remediation, Resource Provisioning,…

Run Windows Commands Remotely

# RPC WMIC /node:SERVER1 process call create 'powershell.exe' # WinRM winrs -r:SERVER1 powershell.exe # Systernals psexec //SERVER1 powershell.exe

HaProxy RDP Forwarding

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp PortNumber = 000001BB frontend fe_rdp_tsc bind 0.0.0.0:443 name rdp_web ssl crt kimconnect.com.pem mode…