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
  • Testing UNC Paths

    Test-Path can test whether or not a given file or folder exists. This works fine for paths that use a drive letter, but can fail with pure UNC paths. At its simplest, this should return $true, and it does (provided you did not disable your administrative...
  • Enabling PowerShell Remoting

    If you'd like to use PowerShell Remoting to execute commands and scripts on another machine, then you need to enable Remoting on the target side with full Admin privileges: On the client side, you do not need to do anything special when you are in...
  • Enabling Classic Remoting

    Many cmdlets have built-in remoting capabilities, for example Get-Service and Get-Process both have the parameter -ComputerName, and so does Get-WmiObject. However, to actually use these cmdlets remotely, the remoting technique employed by the cmdlets...
  • Exporting and Importing Credentials in PowerShell

    Credential objects contain a username and a password. You can create them using Get-Credential, and then supply this object to any cmdlet that has the -Credential parameter. However, what do you do if you want your scripts to run without user intervention...
  • Finding USB Stick Information

    Did you know that Windows logs any USB stick type you ever used? To get that information from the Registry, simply use this function: function Get-USBInfo { param ( $FriendlyName = ' * ' ) Get-ItemProperty -Path ' Registry::HKEY_LOCAL_MACHINE...
  • Finding Time Servers (And Reading All RegKey Values)

    Maybe you'd like to get a list of timeservers registered in the Registry database. Then you probably run code like this: Get-ItemProperty -Path ' Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers ' $path...
  • Finding Expired Certificates

    PowerShell grants access to your certificate stores by using the cert: drive. You can use this drive to find certificates based on given criteria. This would list all certificates that have a date in NotAfter that is before today (indicating expired certificates...
  • Submitting Arguments to EXE Files

    Running applications such as robocopy.exe from PowerShell sometimes is not trivial. How do you submit arguments to the EXE so that PowerShell won't change them? It really is simple: make sure all arguments are strings (so quote the arguments if they...
  • Applying NTFS Access Rules

    There are many ways to add or change NTFS permissions. One is to reuse existing tools such as icacls.exe. This function will create new folders that have default permissions. The script uses icacls.exe to explicitly add full permissions to the current...
  • Profiling Systems

    If you just want to profile a local or remote system and get back the most commonly used pieces of information, then do not waste time for your own solutions. Simply reuse systeminfo.exe, and feed the data into PowerShell: function Get-SystemInfo { param...
  • Running Commands Elevated in PowerShell

    Sometimes, a script may need to run a command that needs elevation (Administrator privileges). Instead of requiring the script to run with full privileges altogether, you can also send individual commands to an elevated shell. This will restart the Spooler...
  • Get-WirelessAdapter

    In the previous tip, we illustrated how you can use Registry information to find wireless network adapters. Here is now a function Get-WirelessAdapter that returns all wireless adapters in your system: function Get-WirelessAdapter { Get-ItemProperty ...
  • Finding Wireless Network Adapters

    There are many ways of finding network adapters, but apparently none to identify active wireless adapters. All information about your network adapters can be found right in the Registry, and here is a one-liner that provides all the information you may...
  • Drive Data in GB and Percent

    When a cmdlet returns raw data, you may want to convert the data into a better format. For example, WMI can report the free space of a drive but reports bytes. You can then use Select-Object and provide hash tables to take the raw data and convert it...
  • Finding Hard Drives Running Low on Storage

    WMI can retrieve information about drives easily. This will get you the drive information for your local machine (use -ComputerName to access a remote system): To limit the results to only hard drives, and only those hard drives that have less than a...
< Previous 1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.