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...
ps1
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...
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...
Managing Windows Defender in Windows 8.1
Windows 8.1 ships with a new module called "Defender". The cmdlets found inside enable you to manage, view and change all aspects of 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...
Exchanging CMD.EXE with POWERSHELL.EXE in Windows 8.1
Windows 8.1 still offers the old cmd.exe command window in some of its context menus. To change that and replace cmd.exe with powershell.exe, in...