database-tools

Finding Files Owned by a User

Here's a simple filter that will show only those files and folders that a specific user is owner of: filter Get-Owner...

Am I Privileged?

There are numerous ways to find out if a script runs elevated. Here's a pretty simple approach: PS> (whoami /all | Select-String...

Checking User Privileges

whoami.exe is a useful little tool that ships with Windows 7/Server 2008 R2, and it becomes even more useful when you instruct it to output its...

Resolving Paths

Paths can be relative, such as ". \file.txt". To resolve such a path and display its full path, you could use Resolve-Path: PS>...

Synchronizing Current Folder

PowerShell allows its own current path to differ from what Windows thinks is the current path: [IO.Path]::GetFullPath('.') cd $env:windir...

Check PowerShell Speed

To find out how much time a particular cmdlet or command takes, here's a handy little stopwatch that you can use: function Test { $codetext =...

Running a Script Block with Parameters

Maybe you want to design a script that takes code as user input. How would you run that submitted piece of code and pass parameters to it? To run a...

Pinning PowerShell ISE

The integrated PowerShell ISE editor has its own icon and can be pinned to the Windows 7 taskbar, just like PowerShell. Try this: Open PowerShell,...

No Reboots After Updates

If you have set Windows Update to automatic mode, it takes care of detecting, downloading, and installing all necessary updates - fine. However, it...

Locking Drive Content

In a previous tip we showed how you can hide drive letters in Windows Explorer. You may have discovered, though, that a user can still open files...

Implicit Foreach in PSv3

PowerShell v3 Beta is available for quite some time now, so every now and then we start tossing in some PowerShell v3 tips. We'll clearly mark...

Hiding Drive Letters

Sometimes you may want to hide drive letters in Windows Explorer from users. There's a Registry key that can do this for you. It takes a bit...

Checking Size of Downloads-Folder

Whenever you download something with IE, by default the files get stored in your personal download folder. Often, over time a lot of garbage can...

Copying Files in the Background

In a previous tip we showed how you can use the BITS service to copy files. The main advantage of BITS is that it can copy things silently in the...

Using Splatting for Better Formatting

Supplying parameters to a cmdet often results in very long lines like this one: Get-ChildItem -Path $env:windir -Filter *.ps1 -Recurse -ErrorAction...

Copying Large Files with BITS

You can use Copy-Item or the console applications xcopy and robocopy to copy large files. But did you know that you can also use the BITS service to...

Matching "Stars"

Asterisk serve as wildcards, so how would you check for the presence of an asterisk? It's much harder than you might think: PS>...

Clearing WinEvent Logs

With Get-WinEvent you can access the various Windows log files such as this one: PS> Get-WinEvent Microsoft-Windows-WinRM/Operational There is no...

Adding Clock to PowerShell Console

Maybe you'd like to include dynamic information such as the current time into the title bar of your PowerShell console. You could update the...

Integrating WhoAmI Into PowerShell

There is a cool little tool called whoami.exe which is part of Windows ever since Windows Vista. Since it can provide results not just in plain text...

Getting Group Memberships

If you'd like to know in which groups you are member, here's a simple piece of code that returns the list of groups you belong to: PS>...

Who am I?

If you'd like to know your current user account, of course you can query environment variables like this: PS> $env:userdomain PS>...

Optimizing PowerShell Performance

PowerShell is loading .NET assemblies. These assemblies can be precompiled using the tool ngen.exe which improves loading times (because the DLLs no...