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
  • Accessing Registry Remote

    If you need to access registry keys and values on another machine, you can either use PowerShell Remote (requires PowerShell v2 on the remote machine), or you can use good old DCOM. Here is how: # NOTE: RemoteRegistry Service needs to run on target system...
  • Reading Password Age

    When you want to find out the password age of Active Directory accounts, you can use this piece of code: function Get-PwdAge { $filter = '(&(objectCategory=person)(objectClass=user))' $root = New-Object System.DirectoryServices.DirectoryEntry...
  • Reading Twitter News

    Have you ever wanted to stay updated on Twitter news? You just need three lines of code to return the latest 100 Twitter entries related to PowerShell: $xml = New-Object xml $xml . load ( "http://search.twitter.com/search.atom?q=powershell&rpp...
  • Control Media Player from PowerShell

    Start your day with your favorite music or playlist by controlling Media Player by PowerShell. Get-MediaPlayerItems will return all playlists and multimedia items accessible. Start-MediaPlayer accepts any one of them and will launch Media Player to play...
  • Getting Non-Expiring Passwords

    You should use a searcher object like this if you need to find all user accounts in your Active Directory with non-expiring passwords: function Get-NonExpiringPasswords { $filter = '(&(objectCategory=person)(objectClass=user)(userAccountControl...
  • Validating Input

    You can also use regular expressions to validate user input. For example, the following piece of code only accepts three seven digit numbers: do { $result = Read-Host "3-7-digit number" $result = $result . Trim ( "0" ) } while ( $result...
  • Mandatory Password Parameters

    If you mark a parameter as mandatory and set its type to "SecureString," PowerShell will automatically prompt for the password with masked characters: function Test-Password { param ( [ System.Security.SecureString ][Parameter(Mandatory = $true...
  • Entering Passwords Securely

    You can use Read-Host -asSecureString to be able to type a password with hidden characters: $password = Read-Host -asSecureString 'Password' This will return a secure string. You should use this to get the password back into plain text: $password...
  • Find Out If A Machine Is Connected To The Internet

    Ever wondered if a machine was connected to the Internet? Here is how you can find out: $networkListManager = [ Activator ]:: CreateInstance ([ Type ]:: GetTypeFromCLSID ([ Guid ] "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" )) $connections = $networkListManager...
  • Sorting IP Addresses

    Sorting or comparing IP addresses won't initially work because PowerShell uses alphanumeric comparison. However, you can compare or sort them correctly by casting IP addresses temporarily to the type System.Version: $iplist = "10.10.10.1"...
  • Speed Up The Reading of Large Text Files

    When you use Get-Content to read in text files, you may initially be disappointed by its performance. However, Get-Content is slow only because it emits each line to the pipeline as it reads the file, which is time-consuming. You can dramatically speed...
  • Accessing Web Services

    Did you know PowerShell can access public and private Web services? The piece of code below will connect to a global weather service providing airport weather reports from around the globe: $a = New-WebServiceProxy 'http://www.webservicex.net/globalweather...
  • Create HTML report in style

    Also, here is a template that shows you how to change to a nicer font if you want to export PowerShell results as HTML report.. It will generate a process list and display it in a simple window: $head = @ ' <style> body { font-family:Consolas...
  • Launching Scripts Externally

    For example, you should use this line if you want to launch a *.ps1 PowerShell script externally from outside PowerShell via desktop shortcut or from inside a batch file: powershell.exe -nologo -executionpolicy bypass -noprofile -file "C:\myscript...
  • Get All Logged On Users

    In a previous tip, you learned how to determine who the user is logged onto the physical machine. However, this will not discover logged-on terminal service users or users inside virtual machines. You must use the code below to find those: $computername...
« First ... < Previous 59 60 61 62 63 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.