There is a tiny .NET function called GetHostByName() that is vastly useful. It will look up a host name and return its current IP address:...
powertips
Reading and Writing NTFS Streams
When a file is stored on a drive with NTFS file system, you can attach data streams to it to store hidden information. Here is a sample that hides...
Create New Local Admin Account on the Fly
Ever needed a new local administrator account for testing purposes? Provided you are already Administrator, and you opened a PowerShell with full...
Launching Any Excel Version
Microsoft Excel is an example of a program that is not easy to launch directly: the path to Excel may be different, depending on Office version and...
Unblocking Download Files
Any file you download from the Internet or receive via email get marked by Windows as potentially unsafe. If the file contains executables or...
Eliminating Empty Results
To exclude results that have empty properties, you can easily use Where-Object. For example, when you run Get-Hotfix, and you only want to see...
Hidden Array Extensions in PowerShell 4.0
PowerShell 4.0 (final version as found in Windows 8.1) has Foreach and Where built directly into arrays. This is a geek stuff, so there is no...
Opening Files in ISE Editor
If you'd like to open a script in the ISE editor, one quick way is using the command "ise". For example, to open your profile script...
Block Comment in PowerShell ISE
Beginning in PowerShell 3.0, when you press and hold ALT and then select something, you get a block selection. If you make this selection as narrow...
Finding Logged-On User on Remote Machine
In a previous tip we used quser.exe to find the currently logged-on user on the local machine. Here is now a function that also allows us to find...
Finding Logged-On User
There is a helpful console application called quser.exe which will tell you who is logged on to a machine. The executable returns plain text, but...
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...
Getting System Information for Remote Systems
In a previous tip you learned how systeminfo.exe can compose a rich system profile. systeminfo.exe has built-in remoting capabilities, so provided...
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...
PowerShell Remoting with Large Token Size
The Kerberos token size depends on the number of group memberships. In some corporate environments with heavy use of group memberships, the token...
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...
Getting Error Events from Multiple Event Logs
Get-EventLog can read events only from one event log at a time. If you want to find events in multiple event logs, you can append array information,...
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...
Getting Yesterday’s Date – at Midnight!
Getting relative dates (like yesterday or one week ahead) is easy once you know the Add…() methods every DateTime object supports. This would...