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
  • Using Enumerations

    Beginning with PowerShell 5.0, you can use the new keyword "enum" to create enumerations. They can be useful for parameter validation: #requires -Version 5 enum MyFavoriteCities { Hannover Seattle London NewYork } function Select-City { param...
  • Remotely Executing Applications on Behalf of Someone Else

    When you remotely execute an application, it will run invisibly on the remote system. Here is some code that illustrates how you can run an application remotely and visibly in the context of another user - provided you have local Administrator privileges...
  • Changing Excel Cells from PowerShell

    If you need to change the content of a specific cell in an Excel spreadsheet, take a look at this sample code: $ExcelPath = ' c:\path..to..some..excel..file.xlst ' $excel = New-Object -ComObject Excel.Application $excel . Visible = $true $workbook...
  • Reading Excel Cells

    The fastest way to read data from an Excel spreadsheet is to export the data to CSV, then use Import-CSV. However, sometimes the data in an Excel sheet is not tabular, or you want to access specific cells. Here is a sample that accesses cells directly...
  • Minimizing All Windows (Part 2)

    If all you need to do is minimizing all open windows, there is the Shell.Application COM object. PowerShell can access its methods via New-Object: $shell = New-Object -ComObject Shell.Application $shell . MinimizeAll () Start-Sleep -Seconds 2 $shell ...
  • Minimizing All Application Windows

    In a previous tip we explained how PowerShell can access low level API functions such as ShowWindowAsync(). Once you better understand how a particular API function works you can use it for many purposes. Here is an example that takes all open application...
  • Accessing API Methods

    PowerShell can use C# to define new .NET types that access the internal Windows API methods. Here is some code that makes accessible the ShowWindowAsync() API function which you can use to control application windows. It minimizes your PowerShell instance...
  • Check Default PowerShell Module Paths

    Sometimes, PowerShell modules ship as MSI packages. When they do, you never know what the installation logic does to your system. Unfortunately, there are module authors who replace rather than add paths to the list of default PowerShell module paths...
  • PSGet is Evil!

    If you have played with the early releases of PowerShellGet and the PowerShell Gallery ( www.powershellgallery.com ), you may still have a module called "PSGet" on your system. If so, this module may conflict with the final version of PowerShellGet...
  • 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...
« First ... < Previous 2 3 4 5 6 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.