PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Forum experts available to answer your PowerShell questions

Power Tips

Power Tips

Syndication

  • Getting System Information for Remote Systems

    In a previous tip you learned how systeminfo.exe can compose a rich system profile. systeminfo.exe has built-in remoting capabilities, so provided you have the proper permissions, you can also get system information from remote systems. Here is a simple...
  • Getting System Information

    PowerShell plays friendly with existing console applications. One of the most useful is systeminfo.exe which gathers all kinds of useful system information. By importing the information provided by systeminfo.exe as CSV, PowerShell can convert the text...
  • Starting Services Remotely

    Since Start-Service has no -ComputerName parameter, you cannot use it easily to remotely start a service. While you could run Start-Service within a PowerShell remoting session, an easier way may sometimes be Set-Service. This would start the Spooler...
  • Using ICACLS to Secure Folders

    Console applications are equal citizens in the PowerShell ecosystem. In this example, a function uses icacls.exe to secure a newly created folder: function New-Folder { param ( $Path , $Username ) If ( ( Test-Path -Path $path ) -eq $false ) { New-Item...
  • Lowering PowerShell Process Priority

    When you run a PowerShell task, by default it has normal priority, and if the things your script does are CPU intensive, the overall performance of your machine may be affected. To prevent this, you can assign your PowerShell process a lower priority...
  • PowerShell Remoting with Large Token Size

    The Kerberos token size depends on the number of group memberships. In some corporate environments with heavy use of group memberships, the token size can grow beyond the limits allowed for PowerShell remoting. In these scenarios, PowerShell remoting...
  • Getting Most Recent Earthquakes

    Everything is connected these days. PowerShell can retrieve public data from web services. So here's a one-liner that gets you a list of the most recently detected earthquakes and their magnitude: Invoke-RestMethod -URI "http://www.seismi.org...
  • Getting Error Events from Multiple Event Logs

    Get-EventLog can read events only from one event log at a time. If you want to find events in multiple event logs, you can append array information, though: $events = @ ( Get-EventLog -LogName System -EntryType Error ) $events += Get-EventLog -LogName...
  • Ordered Hash Tables and Changing Order

    Ordered hash tables are new in PowerShell 3.0 and great for creating new objects. Unlike regular hash tables, ordered hash tables keep the order in which you add keys, so you can control in which order these keys turn into object properties. Here is a...
  • 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...
  • Search and View PowerShell Videos

    PowerShell is amazing. It will let you search YouTube videos for keywords you select, then offer the videos to you, and upon selection play the videos as well. Here's a little script that--Internet access assumed--lists the most recent "Learn...
  • Managing Windows Defender in Windows 8.1

    Windows 8.1 ships with a new module called "Defender". The cmdlets found inside enable you to manage, view and change all aspects of the Windows Defender anti-spyware application. To list all cmdlets available, try this: Get-Command -Module...
  • Searching for Local User Accounts

    Did you know that you can actually search for local user accounts, much like you can search for domain accounts? Here is an example code that searches for all local accounts with a name that starts with "A" and are enabled: Add-Type -AssemblyName...
  • Getting Local Group Members

    In PowerShell, local accounts and groups can be managed in an object-oriented way thanks to .NET Framework 3.51 and above. This will list local administrator accounts: Add-Type -AssemblyName System.DirectoryServices.AccountManagement $type = New-Object...
  • Exchanging CMD.EXE with POWERSHELL.EXE in Windows 8.1

    Windows 8.1 still offers the old cmd.exe command window in some of its context menus. To change that and replace cmd.exe with powershell.exe, in Windows 8.1, right-click the taskbar and choose Properties. Next, click the tab "Navigation" and...
« First ... < Previous 26 27 28 29 30 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.