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
  • Checking Windows Updates

    To check all installed updates on a Windows box, there is a COM library you can use. Unfortunately, this library isn't very intuitive to use, nor does it work remotely. So here is a PowerShell function called Get-WindowsUpdate. It gets the locally...
  • Checking DELL Warranty Online

    PowerShell Version 2.0 and later If you own a DELL computer, you can take advantage of a web service that takes your computer serial number and returns your entitlements: $serial = ' 36GPL41 ' $service = New-WebServiceProxy -Uri http : // 143...
  • Finding AD Accounts Easily

    All PowerShell versions You do not necessarily need additional cmdlets to search for user accounts or computers in your Active Directory. Provided you are logged on to the domain, simply use this: $ldap = ' (&(objectClass=computer)(samAccountName...
  • Identifying Network Vendors by MAC Address

    All PowerShell Versions Each MAC address uniquely identifies a network device. The MAC address is assigned by a network equipment vendor. So you can backtrack the vendor from any MAC address. All you need is the official IEEE vendor list which is more...
  • Wait For Key Press

    Sometimes you'd like to wait for a key press. The easiest way is to use Read-Host like this: Read-Host 'Please press ENTER' | Out-Null Problem here is: Read-Host accepts more than one key and only continues after you press ENTER. To implement...
  • ExpandProperty rocks - sometimes

    Select-Object will select the object properties that you want to see. So it removes all properties you did not specify, but it always returns an object: Get-Process | Select-Object Name Often, you are not interested in an object but prefer the content...
  • Using OpenFile Dialog

    You can use this code to open a standard OpenFile dialog in your PowerShell scripts: [ System.Reflection.Assembly ]:: LoadWithPartialName ( "System.windows.forms" ) | Out-Null $dialog = New-Object System.Windows.Forms.OpenFileDialog $dialog...
  • Creating Calendars (and Lists of Dates)

    Here's a code snippet that creates DateTime ranges. Just specify a year and a month, and the script produces a DateTime object for each day in that month: $month = 8 $year = 2013 1 .. [ DateTime ] :: DaysInMonth ( $year , $month ) | ForEach-Object...
  • Getting Excuses Automatically

    Tired of inventing lame excuses yourself? Then here's a script that gets you a new excuse any time you call Get-Excuse! All you need is Internet access: function Get-Excuse { $url = ' http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl '...
  • Getting Yesterday’s Date - at Midnight!

    Getting relative dates (like yesterday or one week ahead) is easy once you know the Add…() methods every DateTime object supports. This would give you yesterday: $today = Get-Date $yesterday = $today . AddDays ( - 1 ) $yesterday $yesterday will...
  • Pinging Computers

    There are multiple ways how you can ping computers. Here is a simple approach that uses the traditional ping.exe but can be easily integrated into your scripts: function Test-Ping { param ([ Parameter ( ValueFromPipeline = $true )] $Name ) process { ...
  • Use $PSScriptRoot to Load Resources

    Beginning in PowerShell 3.0, there is a new automatic variable available called $PSScriptRoot. This variable previously was only available within modules. It always points to the folder the current script is located in (so it only starts to be useful...
  • Test-Connection with Timeout

    The Test-Connection cmdlet implements a simple ping to check whether a system responds to an ICMP request. Unfortunately, you cannot specify a timeout. Test-Connection defaults to a static timeout of 4 seconds: PS C:\> Test-Connection -ComputerName...
  • Faster Array Manipulations

    The "+=" operator is pretty convenient and can add new elements to an array. If you need this more than once, for example in a loop, then this approach is extremely slow, though. Here is a comparison that also shows how you can speed up array...
  • Using Hash Table as Conditional Code Repository

    It is routine for scripts to check whether a folder exists, and if it is missing, to create it: #requires -Version 1 $path = ' c:\testfolder ' $exists = Test-Path -Path $path if ( $exists ) { $null = New-Item -Path $path -ItemType Directory Write...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.