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

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
  • Pinging Multiple Systems Fast

    Test-Connection can ping multiple computers only sequentially, and it does not let you specify a timeout. So when you need to check a large number of systems, it is very slow. A much faster way is to use the underlying WMI and instruct it to ping multiple...
  • 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...
  • Pinging Computers

    In Windows 8/Server 2012 and better, there is a new cmdlet called Test-NetConnection which lets you check whether a system responds to a given port. PS C:\> Test-NetConnection -ComputerName powershellmagazine.com -CommonTCPPort HTTP ComputerName :...
  • Correct Encoding with PowerShell Remoting

    When you run a native console command via PowerShell remoting, special characters like German Umlauts will be damaged because remoting uses a rather limited encoding. $command = { systeminfo.exe /FO CSV | ConvertFrom-Csv } Invoke-Command -ScriptBlock...
  • Finding Current File System Path

    PowerShell supports not just the file system, so you can set the current path to a different provider (Set-Location). Here is a trick that always gets you the current file system location no matter which provider is currently active: PS C:\> cd hkcu...
  • Creating New Objects by Hash Table Conversion

    Beginning in PowerShell 3.0, you can create pre-initialized objects by using a hash table. Simply add the properties you want to preinitialize, then convert the hash table to the desired type. Here is a practical example: #requires -Version 3 $preInit...
  • Use Get-CimInstance with DCOM

    PowerShell 3.0 added an alternative to Get-WmiObject: Get-CimInstance seems to work very similar and can retrieve information from the internal WMI service: PS C:\> Get-WmiObject -Class Win32_BIOS SMBIOSBIOSVersion : A03 Manufacturer : Dell Inc. Name...
  • Understanding PowerShell Streams

    PowerShell provides seven different streams you can use to output information. Streams help sort out information because streams can be muted. In fact, some streams are muted by default. Here is a sample function called Test-Stream. When you run it, it...
  • Loading a Base64-encoded Picture into WPF Window

    In a previous tip we illustrated how you can convert any picture into a Base64-encoded string. Today, we'd like to show how you can load a picture from a Base64-encoded string and display it. The example code creates a WPF window inviting you to the...
  • Encoding Pictures

    If your script needs resources such as icons or pictures, you do not have to ship these resources separately. They can be Base64-encoded and added to your script as plain text. This example illustrates how to convert a JPG picture into a Base64-encoded...
  • Encode and Decode Text as Base64

    Here is a simple way to encode text as a Base64 string: #requires -Version 1 $text = ' Hello World! ' [ Convert ] :: ToBase64String ([ System.Text.Encoding ] :: Unicode . GetBytes ( $text ) , ' InsertLineBreaks ' ) The resulting text looks...
  • Managing Windows Firewall

    Beginning in Windows 8 and Server 2012, there is a cmdlet that helps you enable the client firewall for various profiles: Set-NetFirewallProfile -Profile Domain , Public , Private -Enabled True In previous operating systems, you have to resort to netsh...
  • Finding Recursive AD Memberships

    In AD, there is a strange-looking filter: 1.2.840.113556.1.4.1941. It is called "matching rule in chain" and can be used to quickly find nested memberships. All you need is the DN of a member. Then, you can use it like this: #requires -Version...
  • Clearing Recycle Bin

    Before the advent of PowerShell 5.0, to clear the recycler, you would have to manually delete the content of the hidden $Recycle.Bin folder in the root of all drives that have a recycler. Some authors recommended the use of a COM object called Shell.Application...
  • Force User to Change Password

    Use this code snippet to force a user to change his/her password: #requires -Version 1 -Modules ActiveDirectory Set-ADUser -Identity username -ChangePasswordAtNextLogon $true ReTweet this Tip!
< Previous 1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.