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...
Powershell
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...
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...
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...
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...
Get Localized Month Names
To get a list of month names, you could use this line: PS>...
Creating Symmetric Array
By default, PowerShell uses jagged arrays. To create conventional symmetric arrays, here's how: PS> $array = New-Object 'Int32[,]'...
Finding Domain Controllers
If your computer is logged on to an Active Directory, here is some code to get to your domain controllers. Note that this will raise errors if you...