PowerShell v2 Snippets

Here is a new, hopefully ever expanding library of PowerShell snippets.

Set PowerShell Current Working Directory
To set current working directory to current directory currently navigated to use

[IO.Directory]::SetCurrentDirectory((Convert-Path (Get-Location -PSProvider FileSystem)))
or
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath

These snippets are from: http://huddledmasses.org/powershell-power-user-tips-current-directory/

Execute WMI Query
Get-WmiObject -Query "Select * from Win32_Process WHERE Caption=""Notepad.exe"""

Checkout WMI Query Language (WQL) – An introduction at http://www.ravichaganti.com/blog/?p=1509 for some great resources on PowerShell querying examples.

Download PDF
This entry was posted in PowerShell, Snippets and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *