PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Forum experts available to answer your PowerShell questions

Power Tips

Power Tips

Syndication

  • Magic Underscore Variable

    Here is a very special (and very underdocumented) way to use PowerShell parameters. Have a look at this function: #requires -Version 2 function Test-DollarUnderscore { param ( [ Parameter ( Mandatory = $true , ValueFromPipelineByPropertyName = $true ...
  • Converting Currencies

    PowerShell is an extremely powerful language and can access web services and web pages. If you combine that with dynamic parameters, you get a professional currency converter with real-time exchange rate support. Here is the ConvertTo-Euro function that...
  • Counting Pages in a Word Document

    Let's assume you have a bunch of Word files and would like to know how much pages they contain. Here is a function that takes the path to one Word file and determines its page count: #requires -Version 1 # adjust path to point to an existing Word...
  • Bringing Window in the Foreground

    PowerShell can use Add-Type to access internal Windows API functions. This way, it is easy to bring any process window into the foreground. Here is the function you need: #requires -Version 2 function Show-Process($Process, [ Switch ] $Maximize ) { $sig...
  • Process Data (Part 3)

    In parts 1 and 2, you learned how a PowerShell function can process information that was submitted to parameters or piped via the pipeline. In our third part, we'd like to show how a function can receive text lines and produces one string from it...
  • Process Data (Part 2)

    In part 1 we showed how a PowerShell function can receive input both from a parameter and via the pipeline, and process it in real-time. This is the most efficient way as it minimizes memory consumption. Sometimes, however, it is necessary to first collect...
  • Processing Data (Part 1)

    This is the first of the three tips showing you how a PowerShell function can accept data via pipeline or parameter. In part 1, the function processes the incoming information in real-time. This minimizes memory consumption and provides rapid results...
  • Get UI Information for Processes

    PowerShell can use UIAutomation calls to find out useful UI information about any process. You can find out whether a process accepts keyboard input, whether it is currently visible (and what its window dimensions are), and whether it is a native Win32...
  • PowerShell 5.0 RTM (was) available

    Shortly before Christmas, PowerShell 5.0 RTM was made available to all Windows versions down to Windows 7: http://blogs.msdn.com/b/powershell/archive/2015/12/16/windows-management-framework-wmf-5-0-rtm-is-now-available.aspx . Unfortunately, there was...
  • Compressing to ZIP Files

    In PowerShell 5.0, Compress-Archive can easily compress files and folders to a ZIP file: PS C:\> Compress-Archive -Path c:\sourcefolder -DestinationPath $env:temp\archive.zip -Force Compress-Archive is not a cmdlet, though. It is a function and leverages...
  • Quickly Scanning for Malware

    If you have Windows Defender installed on your machine, you can use this PowerShell command to run a quick scan on a drive of your choice: PS> Start-MpScan -ScanType QuickScan -ScanPath “C:” This command requires the "Defender"...
  • Enabling Telnet Client and Watching Star Wars

    By default, the Telnet client is disabled on Windows systems. You can easily enable it with a one liner in PowerShell, though. Just launch a PowerShell with full Administrator privileges, then run this command: PS C:\> dism /online /Enable-Feature...
  • Enabling PowerShell Remoting with NTLM

    By default, PowerShell remoting uses Kerberos authentication and works only in domain environments, and only when you specify computer names, not IP addresses. To use PowerShell remoting in other scenarios such as peer-to-peer networks at home or in labs...
  • Validate Read-Host Input

    Beginning in PowerShell 4.0, you can use validators for variable assignments. This gives you a quick and easy way of validating user input, too. The next line accepts only user input that matches the regular expression in the validator. It only accepts...
  • Restore PowerShell ISE Defaults

    To restore custom settings in PowerShell ISE to factory defaults, try running these lines: $PSise . Options . RestoreDefaults () $PSise . Options . RestoreDefaultConsoleTokenColors () $PSise . Options . RestoreDefaultTokenColors () $PSise . Options ....
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.