Powershell

Getting DNS IP Address from Host Name

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:...

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...

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...

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

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...

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...

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...

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...

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...

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...

Managing Office365 with PowerShell

Did you know that you can manage your Office365 accounts with PowerShell, too? Provided you have an Office365 account, try this: $OfficeSession =...

1 62 63 64 65 66 104