Here's a simple filter that will show only those files and folders that a specific user is owner of: filter Get-Owner...
database-tools
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,...
Keyboard Tricks for Launching PowerShell
If you have pinned PowerShell to your taskbar (on Windows 7: launch PowerShell, right-click its icon in the task bar, choose "Pin this program...
Consider Your Collations Carefully, Or Pay Later
When first installing SQL Server, many developers and DBAs new to SQL Server may have the temptation to click Next, Next, Next on the installation...
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...
Ensure Proper SQL Server Connection Pooling
Coming to SQL Server from both a database developer and DBA background, I maintain that while tuning SQL Server’s ability to handle your application...
Using PowerShell ISE with Full Privileges
Sometimes you need full administrator privileges to debug or test a script in the ISE script editor. By default, ISE starts with restricted...
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...
Converting Letters to Numbers and Bit Masks
Sometimes, you may need to turn characters such as drive letters into numbers or even bit masks. With a little bit of math, this is easily doable....
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>...
Extract Paths from Strings Like Environment Variables
If you'd like to add a path to the %PATH% environment variable, that's easy: PS> $env:path += '
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...