Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

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
  • Remove Recents Folder

    Windows uses the special recents folder to remember which files you have opened. You can have a look to check what Windows has stored: Dir ([ Environment ]:: GetFolderPath ( "Recent" )) To get rid of that information, delete the folder content...
  • Bulk-Changing File Extensions

    Changing file extensions can be a quick one-line operation. The next line renames all ps1 PowerShell script files found in your user profile and renames them to the new extension "old.ps1." This way, they stay PowerShell scripts, but get an...
  • Displaying Hex Dumps

    PowerShell can read plain text, but it can also read binary content. Here is a little function that creates a "hex dump" of any binary file: function Get-HexDump ( $path , $width = 10, $bytes =- 1) { $OFS = "" Get-Content -Encoding...
  • Reading File "Magic Number"

    File types are not entirely dependent on file extension. Rather, binary files have internal ID numbers called "magic numbers" that tell Windows what type of file it is. Here is a function to read and display the magic number: function Get-MagicNumber...
  • Working with Path Names

    The .NET System.IO.Path class has a number of very useful static methods that you can use to extract file extensions. Here is how you can get a list of available methods: [ System.IO.Path ] | Get-Member -Static And here is an example on how to use one...
  • Finding A Users Desktop Folder

    The .NET Environment class can provide the paths to common folders like a user desktop: Environment]:: GetFolderPath ( "Desktop" ) Use this line to get a list of allowed folder names: [ Enum ]:: GetNames ([ System.Environment + SpecialFolder...
  • Writing Your Own Event Log Entries

    If you have registered a new event log source, such as "PowerShellScripts" as described in the previous tip, you can now write your own Events: Write-EventLog -LogName Application -Source PowerShellScripts -EntryType Warning -EventId 12345 ...
  • Adding New Event Log Sources

    Every event log maintains a list of registered sources. You need a source name if you want to write your own event log entries. Make sure you have administrator privileges to add a new source called "PowerShellScripts" to your application log...
  • Lowering Process Priority

    Sometimes, you may want to lower process priority for some processes. That's a PowerShell one liner. Note that the next line lowers priority for all Notepad processes to "below normal:" Get-Process notepad | ForEach-Object { $_ . PriorityClass...
  • Getting Help on WMI Methods

    Have you ever wanted to get a list of all WMI methods present inside a specific WMI class – plus a meaningful description and a list of all the supported return values? Here is how: $class = [ wmiclass ] "Win32_NetworkAdapterConfiguration"...
  • Renewing all DHCP Leases

    Some WMI classes contain static methods. Static methods do not require an instance. ([ wmiclass ] "Win32_NetworkAdapterConfiguration" ). RenewDHCPLeaseAll (). ReturnValue ReTweet this Tip!
  • Calling ChkDsk via WMI

    Some WMI classes contain methods that you can call to invoke some action. For example, the next line initiates a disk check on drive D: ([ wmi ] "Win32_LogicalDisk='D:'" ). Chkdsk ( $true , $false , $false , $false , $false , $true ...
  • Getting Help for WMI Classes

    In a previous tip, you discovered how to search for WMI classes like Win32_VideoController. Now, what exactly is the purpose of this class? You can retrieve Help information for any WMI class with the next lines of code,: $class = [ wmiclass ] 'Win32_VideoController'...
  • Finding Interesting WMI Classes

    WMI is a huge repository. If you want to get to useful information, you will need to specify the name of a valid WMI class. Fortunately, it is easy to search for interesting classes. You can simply use Get-WmiObjectand the -list parameter in conjunction...
  • Rename Drive Label

    WMI can also read any drive label (the name that appears next to a drive inside Explorer), and you can change the drive label, too—provided you have administrator privileges. This code renames drive c:\ to "My Harddrive": $drive = [ wmi...
« First ... < Previous 72 73 74 75 76 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.