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

Archives

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
  • Converting 8.3 File Names

    If you want to convert a short 8.3 filename to its long file name, try something like this: PS> (Get-Item "$env:systemdrive\progra~1").Name Program Files ReTweet this Tip!
  • Extracting Icons

    PowerShell can use C# source code to access internal Windows APIs. Here is an example that illustrates how you access icons from DLLs and EXEs and save them to disk: # adjust these $DLL = " $env:windir\system32\shell32.dll " $IconIndex = 20...
  • Use PowerShell 5.0 Code Generation API

    In PowerShell 5.0, a new .NET type was introduced that can help you escape text information so it can be displayed correctly: PS> [System.Management.Automation.Language.CodeGeneration] | Get-Member -Static TypeName: System.Management.Automation.Language...
  • Cleaning Week: Removing Traces (Recents)

    Cleaning week comes to an end. As a last part, you may want to check the list of files you recently opened. This list is full of privacy sensitive information, and the files listed here are not necessarily “recent”. If you never clean up the...
  • Cleaning Week: Getting Rid of Downloads

    Do you really need all the files you downloaded in Windows? It may pay off to look at the downloads, and delete downloaded files you no longer need. The sample code shows a lot of things: how you find your downloads folder path, and how you use Out-GridView...
  • Cleaning Week: Deleting CBS Log File

    Windows maintains a log file named cbs.log in $env:windir\logs\cbs. It logs various pieces of information related to the Windows trusted installer, for example the installation of windows updates, and can grow massively in size. That’s why Windows...
  • Cleaning Week: Deleting Log File Backups

    In a previous tip you learned that there may be gigabytes worth of log file CAB files. Today, let’s try and have PowerShell do the cleanup. All of these CAB files can safely be removed. #requires -Version 3 #Requires -RunAsAdministrator # must run...
  • Cleaning Week: Finding Fat Log File Backups

    When you run a Windows box for a couple of months or even years, a lot of disk space can be wasted by backed up log files that are not needed. So if your hard drive runs full, you may want to check how many of these log files you have, and how much space...
  • Cleaning Week: Deleting TEMP Files

    In a previous tip you learned how to check for left-over files in both your own temp folder and the one maintained by Windows. Today, let’s see how these folders can be cleaned up by PowerShell. This code removes all files that haven’t changed...
  • Cleaning Week: Find Data Garbage

    This week is cleaning week, and we’ll show you tactics how you can potentially retrieve gigabytes of disk space, especially with machines that have been running for a while. You may know about your personal temp folder ($env:temp), and maybe you...
  • Finding Paths to Special Locations

    If you’d like to access any of the following special locations, then we have good news for you: PS C:\> [System.Enum]::GetNames([System.Environment+SpecialFolder]) Desktop Programs MyDocuments Personal Favorites Startup Recent SendTo StartMenu...
  • Copy Over PowerShell Remoting Sessions

    You can use PowerShell remoting to transfer files across a network – this is new in PowerShell 5.0. This can be useful in closed environments where you have no SMB file shares. It is not very efficient (and slow) though. Here is an example: # Create...
  • One-Liner Random Password Generator

    Check out this simple way of creating temporary passwords: -join ( ' abcdefghkmnrstuvwxyzABCDEFGHKLMNPRSTUVWXYZ23456789$%&*# ' . ToCharArray () | Get-Random -Count 8 ) You can easily vary the password length: change the number for -Count to...
  • Harvesting Reboot Time from EventLog

    In the previous tip we illustrated how you can ask WMI for the last reboot time of a machine. A more robust way is to query the Windows event logs. Here is how: # get the latest reboot event from the System event log $e = Get-EventLog System -Source Microsoft...
  • Last Bootup Time with Get-CimInstance

    These days, computers hibernate or go into standby but do not really reboot that often anymore. To find out when your computer rebooted the last time, try this line in PowerShell 3.0 or better: Get-CimInstance -Class Win32_OperatingSystem | Select-Object...
< Previous 1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.