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
  • Beware of Changes to PSModulePath

    PowerShell 3+ PowerShell examines the $env:PSModulePath environment variable to find out the locations where it searches for extension modules. A little known fact is that the content of this variable is partially synthesized. And this can become a big...
  • The Truth About WinRM

    PowerShell 3+ The popular winrm command to manage and configure PowerShell Remoting is really just a batch and a VBS file: PS> Get-Command winrm -All | ft -AutoSize CommandType Name Version Source ----------- ---- ------- ------ Application winrm.cmd...
  • Listening to Music in the Background

    PowerShell 3+ In the previous tip we presented to you a “Dancing Rick ASCII”, created by Lee Holmes. Lee uses music stored on his server as background. Here is an example that illustrates how you can spawn a background thread, and for example...
  • Smuggling In PowerShell Code

    PowerShell 2 There is a good reason why Invoke-Expression is considered risky. This cmdlet executes whatever string it gets, and attackers can download malicious code from the Internet, bypass script analysis, and execute it. Here is a benign example...
  • Display Windows

    PowerShell 3+ It is fairly easy to use WPF (Windows Presentation Foundation) to create and show simple dialog windows in PowerShell. If you’d like to display a quick message, check this out: Add-Type -AssemblyName PresentationFramework $window ...
  • Add a Clock to PowerShell

    PowerShell 2+ Here is a fun example that illustrates how to work with timers. It adds a clock to the title bar of the PowerShell console or the PowerShell ISE. Simply run the script, then call Start-Clock to start the clock, and Stop-Clock when you want...
  • Changing Page File Location

    PowerShell 2+ To move the Windows page file to a new location, you can use WMI: #requires -Version 2 $args = @ { Name = "D:\pagefile.sys" ; InitialSize = 0 ; MaximumSize = 1 GB } Set-WmiInstance -Class Win32_PageFileSetting -Arguments $args...
  • Encrypting and Decrypting Secret Strings

    When there is the need to encrypt sensitive data, scripts always face the challenge to protect the secret key used to decrypt. If the secret is to be read from the same person that encrypted it, for example, a password that you use in your daily routine...
  • Finding Groups of Logged On User

    If you’d like to know the group memberships of the currently logged on user (the one that is running a script), you don’t need to query the Active Directory. Instead, examine the access token. It contains all effective group memberships, including...
  • Creating Dynamic Variable Content

    PowerShell 2+ In the previous tip we introduced variables with read-only dynamic content that updated each time the variable was read. This required a little bit of C# code. With Add-Member, you can get a similar result using script properties: $info...
  • Creating Dynamic Variable Content

    PowerShell 2+ A little-known fact is that you can add variables to PowerShell that automatically update their content. If you need random numbers, for example, this code would add a new variable called $Random that provides a new random number each time...
  • Create Simple PowerShell Host

    PowerShell 2 or better There are sometimes a lot of good reasons why you’d like to run a script by a different host. powershell.exe might be blocked by an AppLocker policy, or you’d like to run a PowerShell script invisible, without displaying...
  • Creating PowerShell Web Server

    All Versions Here is an example that implements a simple web server with just a few lines of code. When you run this script, you can enter one of these URLs into any web browser on your machine: http://localhost:8080/ http://localhost:8080/services And...
  • Changing Password

    All versions Here is a simple way how an existing user can change the password for his account. The user must know his old password and does not need Administrator privileges. Make sure you change the user details at the beginning of this script: $username...
  • Opening PowerShell for Folder

    Any version If you browsed to a folder using File Explorer, and then would like to open a PowerShell with the current folder set to the browsed folder, just click the address bar in File Explorer, and replace the path with the “powershell”...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.