Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus


13 Free SQL Tools from Idera


Free Ebook: Mastering Powershell

Welcome to the archive of tips delivered through Tobias' Tip of the Day RSS Feed and Your Power Tip of the Day email. Subscribe in the sidebar to get the latest tips!

Sort by: Most Recent | Most Viewed | Most Commented
  • Creating Colorful HTML Reports

    All PowerShell versions To turn results into colorful custom HTML reports, simply define three script blocks: one that writes the start of the HTML document, one that writes the end, and one that is processed for each object you want to list in the report...
  • Creating New Shares

    All PowerShell versions WMI can easily create new shares. Here is sample code that will create a local share: $ShareName = ' NewShare ' $Path = ' c:\123 ' If ( ! ( Get-WmiObject -Class Win32_Share -Filter "name='$ShareName'"...
  • Useful Path Manipulation Shortcuts

    All PowerShell Versions Here are a bunch of useful (and simple to use) system functions for dealing with file paths: [ System.IO.Path ] :: GetFileNameWithoutExtension ( ' file.ps1 ' ) [ System.IO.Path ] :: GetExtension ( ' file.ps1 ' ...
  • Getting Active Directory Account Information

    In a previous script you have discovered how easy it is to find Active Directory accounts with just some simple PowerShell code. The result is a search result object, not the actual account object. To get more detailed information about an account, use...
  • Searching in Different Domains

    When you use the ADSISearcher type accelerator to find Active Directory accounts, it defaults to the current domain you are logged on to. If you need to find an account in a different domain, make sure you define the search root accordingly. This example...
  • Obfuscating Credentials

    How can you securely embed confidential passwords in a PowerShell script? You can't. But you can make it harder for people to discover the secret. Here is a code generator script that is designed to run inside the PowerShell ISE editor: # ask for...
  • 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 function that changes the wallpaper immediately: function Set-Wallpaper { param ( [ Parameter ( Mandatory = $true...
  • Speaking English and German (and Spanish, and you name it)

    Windows 8 is the first operating system that comes with fully localized text-to-speech engines. So you can now have PowerShell speak (and curse) in your mother tongue. At the same time, there is always an English engine, so your computer is now bilingual...
  • 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: [ System.Net.DNS ] :: GetHostByName ( ' someName ' ) With just a simple PowerShell wrapper, this is turned...
  • Use Open File Dialog

    All PowerShell versions To add some sophistication to your script, here is a simple function that opens the OpenFile dialog and lets the user pick a file. function Show-OpenFileDialog { param ( $Title = ' Pick a File ' , $Filter = ' All|*...
  • Finding Process Owner

    PowerShell Version 3 or better Get-Process gets you a list of all running processes, but it will not reveal the process owner. To find the process owner, you would need to ask the WMI service, for example. To make this easier, here is a little helper...
  • Invoke-Expression is Evil

    It can't be reiterated too often: try and avoid the use of Invoke-Expression (Alias: iex). This cmdlet executes whatever it receives and is prone to SQL-injection like attacks. Take a look at this strange one-liner, and run it in a PowerShell console...
  • Piping Results Straight Into Office Word

    With only a few lines of code you can implement a command called Out-OfficeWord. It takes the data you pipe into it and inserts them into a new Word document (provided Word is installed). #requires -Version 1 function Out-OfficeWord { param ( $Font =...
  • Why Invoke-Expression is Evil

    Invoke-Expression takes any string and treats it as PowerShell code. This way, you could construct dynamic code, and then execute it. Invoke-Expression is a very dangerous cmdlet because not only you can create dynamic code. Malicious scripts could mask...
  • Unfolding Object Data Structure

    PowerShell 3.0 and later Objects can contain nested properties, and the data you are after may be “somewhere” inside an object. To display an object with all of its properties and subproperties expanded, convert it to JSON. This gives you...
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.