PowerShell Import-Csv Declare Types

When importing a CSV into a PowerShell object, each field will be declared as a [string] which breaks sorting and makes working with the data difficult. Thankfully there is a way to declare types which will be showed below. An excerpt of the data I’m working with is as follows: To import this data into […]

Quickly Generate Hex Range with PowerShell

While participating in a recent SANS NetWars, I needed to iterate through a range of hex values and found a quick way to achieve this via PowerShell. Creates an array from 00 to ff. Creates an array from 0000 to ffff. Creates an array from 0000 to 00ff.

Convert Unicode to Decimal with PowerShell

A recent piece of malware used encoding techniques in a Matryoshka doll type fashion to evade detection. One of those layers consisted of Unicode strings like the following snippet: Thankfully I came across the following post on Happy SysAdm: Working with Unicode scripts, blocks and categories in Powershell This lead to the following snippet of […]

Generating Passwords with PowerShell

Password reuse is not a good practice. If there’s any doubt, there are great discussions about this on security.stackexchange.com. So while being vigilant to have unique passwords for each account/service, the following PowerShell scripts have been quite useful. Specific or Limited Character Set Some accounts/services require a specific set of characters. For those instances, the […]

PowerShell Command History

I was watching PowerShell Uncensored – Jaap Brasser & Jason Yoder where a number of useful tips were provided. One of the most interesting items was command logging via the PSReadLine module. Loaded by default it will log all commands typed into a PowerShell window. Even passwords that are not provided via secure prompts/methods. This […]

Microsoft Event Log Alerting

For those that can’t afford a costly monitoring system (SCOM) or don’t want to manage a large open source product (NAGIOS), one can leverage native OS functionality for creating alerts. In this example, there will be two parts: Part 1 – Scheduled Task In a Microsoft environment, this is the preferred method for automating reoccurring […]

PowerShell HTTP Listener

I had to transfer a file between two systems running Windows where only one of them had internet connectivity. In the Linux realm one would use netcat to transfer the file. While netcat isn’t a native tool on Windows it does have PowerShell and all of .NET thus allowing one to create an HTTP listener […]

Restoring NTFS Permissions with PowerShell Set-Acl

When administering a system, there are times when folders need to be relocated to a different location. Perhaps the current location no longer has enough space or perhaps a “Best Practices” document suggests a new location. Either way, the most difficult part of the relocation process is ensuring the NTFS permissions are properly set on […]