June 2012 - 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
  • Stopping Services Remotely

    Stop-Service cannot stop services remotely. One easy way of doing so is Set-Service: Set-Service -Name Spooler -Status "Stopped" -ComputerName targetcomputer However, unlike Stop-Service, Set-Service has no -Force parameter, so you cannot stop...
  • Easier ForEach/Where-Object in PSv3

    In the upcoming PowerShell v3 which you can already download as a Beta version, using Where-Object and ForEach-Object becomes a lot simpler. No longer do you need a script block and code. This, for example, is all you need to find files larger than 1MB...
  • Lunch Time Alert

    Here's a fun prompt function that turns your input prompt into a short prompt and displays the current path in your PowerShell window title bar. In addition, it has a lunch count down, displaying the minutes to go. Three minutes before lunch time...
  • Finding Files Owned by a User

    Here's a simple filter that will show only those files and folders that a specific user is owner of: filter Get-Owner ( $Account = "$env:UserDomain\$env:USerName" ) { if (( Get-ACL $_ . Fullname ) . Owner -like $Account ) { $_ } } It is...
  • Am I Privileged?

    There are numerous ways to find out if a script runs elevated. Here's a pretty simple approach: PS > ( whoami /all | Select-String S - 1 - 16 - 12288 ) -ne $null ReTweet this Tip!
  • Checking User Privileges

    whoami.exe is a useful little tool that ships with Windows 7/Server 2008 R2, and it becomes even more useful when you instruct it to output its result in CSV format. PowerShell can pick up CSV data and turn it into rich objects: PS > whoami /ALL /FO...
  • Resolving Paths

    Paths can be relative, such as ". \file.txt". To resolve such a path and display its full path, you could use Resolve-Path: PS > Resolve-Path .\file.txt Unfortunately, though, Resolve-Path expects the file to really exist, so you cannot use...
  • Synchronizing Current Folder

    PowerShell allows its own current path to differ from what Windows thinks is the current path: [ IO.Path ] :: GetFullPath ( ' . ' ) cd $env:windir Get-Location [ IO.Path ] :: GetFullPath ( ' . ' ) So, whenever you want to use one of the...
  • Check PowerShell Speed

    To find out how much time a particular cmdlet or command takes, here's a handy little stopwatch that you can use: function Test { $codetext = $Args -join ' ' $codetext = $ExecutionContext . InvokeCommand . ExpandString ( $codetext ) $code...
  • Running a Script Block with Parameters

    Maybe you want to design a script that takes code as user input. How would you run that submitted piece of code and pass parameters to it? To run a submitted script block, use Invoke-Command. This cmdlet can run script blocks locally and remote, and it...
  • Pinning PowerShell ISE

    The integrated PowerShell ISE editor has its own icon and can be pinned to the Windows 7 taskbar, just like PowerShell. Try this: Open PowerShell, and launch ise: PS > ise (If ISE does not start, you may be working on a server. ISE is not installed...
  • Keyboard Tricks for Launching PowerShell

    If you have pinned PowerShell to your taskbar (on Windows 7: launch PowerShell, right-click its icon in the task bar, choose "Pin this program to taskbar"), then a click on the icon will open PowerShell. Here are three neat tricks: First, move...
  • No Reboots After Updates

    If you have set Windows Update to automatic mode, it takes care of detecting, downloading, and installing all necessary updates - fine. However, it also automatically takes care of rebooting if required. To turn off automatic rebooting while a user is...
  • Locking Drive Content

    In a previous tip we showed how you can hide drive letters in Windows Explorer. You may have discovered, though, that a user can still open files and folders on hidden drives if he knows the path. So here's a very similar function. It will not hide...
  • Using PowerShell ISE with Full Privileges

    Sometimes you need full administrator privileges to debug or test a script in the ISE script editor. By default, ISE starts with restricted privileges (when Windows User Account Control (UAC) is enabled). To launch ISE with full privileges, right-click...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.