database-tools

Finding Logon Failures

Whenever someone logs on with invalid credentials, there will be a log entry in the security log. Here is a function that can read these events from...

Change Desktop Wallpaper

To change the current desktop wallpaper and make this change effective immediately, PowerShell can tap into the windows API calls. Here is a...

Using Block Comment in the ISE Editor

There is a little known trick that you can use to block-prepend or block-remove characters in the ISE editor. This feature was introduced in...

Getting System Information

PowerShell plays friendly with existing console applications. One of the most useful is systeminfo.exe which gathers all kinds of useful system...

Starting Services Remotely

Since Start-Service has no -ComputerName parameter, you cannot use it easily to remotely start a service. While you could run Start-Service within a...

Using ICACLS to Secure Folders

Console applications are equal citizens in the PowerShell ecosystem. In this example, a function uses icacls.exe to secure a newly created folder:...

Lowering PowerShell Process Priority

When you run a PowerShell task, by default it has normal priority, and if the things your script does are CPU intensive, the overall performance of...

Getting Most Recent Earthquakes

Everything is connected these days. PowerShell can retrieve public data from web services. So here's a one-liner that gets you a list of the...

Ordered Hash Tables and Changing Order

Ordered hash tables are new in PowerShell 3.0 and great for creating new objects. Unlike regular hash tables, ordered hash tables keep the order in...

Search and View PowerShell Videos

PowerShell is amazing. It will let you search YouTube videos for keywords you select, then offer the videos to you, and upon selection play the...

Searching for Local User Accounts

Did you know that you can actually search for local user accounts, much like you can search for domain accounts? Here is an example code that...

Getting Local Group Members

In PowerShell, local accounts and groups can be managed in an object-oriented way thanks to .NET Framework 3.51 and above. This will list local...

Managing Office365 with PowerShell

Did you know that you can manage your Office365 accounts with PowerShell, too? Provided you have an Office365 account, try this: $OfficeSession =...

Displaying Path Environment Variables

The environment variable $env:Path lists all paths that are included in the Windows search path when you launch an application. Likewise,...

Finding Disk Partition Details

To view disk partitioning information, use WMI: Get-WmiObject -Class Win32_DiskPartition | Select-Object -Property * Next, pick the properties you...

Use a Lock Screen

With WPF, PowerShell can create windows in just a couple of lines of code. Here's a funny example of a transparent screen overlay. You can call...

Creating Temporary Password

Here's a chunk of code that creates random passwords of different lengths for you: $length = 8 $characters = [Char[]]((31..50) + (65..90) +...

Obfuscating Credentials

How can you securely embed confidential passwords in a PowerShell script? You can't. But you can make it harder for people to discover the...

Create a Folder Selector

To add a little glamour to your scripts, here are a few lines of code that display a folder selector dialog. When a user selects a folder, your...

Getting Folders by Prefix

Did you know that Group-Object can easily group elements by custom criteria? Here's a line that groups folders by their first three letters:...

Finding Known USB Drives

Did you know that Windows maintains a list of all USB storage devices ever hooked up to your machine? And it's simple to dump that list: $Path =...

Getting DLL File Version Info

Ever needed a list of DLL files and their versions? Get-ChildItem can get this information for you. You just need to unpack some properties like so:...