<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Power Tips</title><subtitle type="html" /><id>http://powershell.com/cs/blogs/tips/atom.aspx</id><link rel="alternate" type="text/html" href="http://powershell.com/cs/blogs/tips/default.aspx" /><link rel="self" type="application/atom+xml" href="http://powershell.com/cs/blogs/tips/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.30929.2835">Community Server</generator><updated>2010-02-23T08:00:00Z</updated><entry><title>Export CSV with Culture-Specific Delimiter</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/15/export-csv-with-culture-specific-delimiter.aspx" /><id>/cs/blogs/tips/archive/2010/03/15/export-csv-with-culture-specific-delimiter.aspx</id><published>2010-03-15T13:00:00Z</published><updated>2010-03-15T13:00:00Z</updated><content type="html">&lt;p&gt;Export-CSV used to only support the comma as separator, which caused problems on non-U.S.-systems. In PowerShell v.2, with -useCulture you can have Export-CSV use whatever delimiter is the right one, depending on your culture.&lt;/p&gt;
&lt;p&gt;There is only one caveat: You should never combine -useCulture with -Encoding Unicode. This seems to be a bug where the culture-specific delimiter is not inserted correctly, which causes importing applications, such as Export, to ignore it.&lt;/p&gt;
&lt;p&gt;You should use -Encoding UTF8 instead if you want to preserve special characters in your export:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Process&lt;/span&gt; | &lt;span class="verbnoun"&gt;Select-Object&lt;/span&gt; Name, Company | &lt;br /&gt;  &lt;span class="verbnoun"&gt;Export-CSV&lt;/span&gt; &lt;span class="modifier"&gt;-useCulture&lt;/span&gt; &lt;span class="modifier"&gt;-Encoding&lt;/span&gt; UTF8 &lt;span class="var"&gt;$home&lt;/span&gt;\&lt;span class="namespace"&gt;export.csv&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Export+Culture-Specific+CSV+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FaK8jvt" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Export+Culture-Specific+CSV+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FaK8jvt" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4683" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Stopping the Pipeline</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/12/stopping-the-pipeline.aspx" /><id>/cs/blogs/tips/archive/2010/03/12/stopping-the-pipeline.aspx</id><published>2010-03-12T14:00:00Z</published><updated>2010-03-12T14:00:00Z</updated><content type="html">&lt;p&gt;Usually, once a pipeline runs, you cannot stop it prematurely, even if you already received the information you were seeking. Simply use this filter to stop a pipeline:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;filter&lt;/span&gt; &lt;span class="verbnoun"&gt;Stop-Pipeline&lt;/span&gt;([&lt;span class="optional"&gt;scriptblock&lt;/span&gt;]&lt;span class="var"&gt;$condition&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; {&lt;span class="var"&gt;$true&lt;/span&gt;}) {&lt;br /&gt;&lt;span class="var"&gt;$_&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="op"&gt;&amp;amp;&lt;/span&gt; &lt;span class="var"&gt;$condition&lt;/span&gt;) {&lt;span class="keyword"&gt;continue&lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;Now, to stop a pipeline, use it like this:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-EventLog&lt;/span&gt; Application | &lt;span class="verbnoun"&gt;Stop-Pipeline&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;InstanceID&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; 10000}&lt;/div&gt;
&lt;p&gt;This will get you all Application events until you find one with an InstanceID of greater than 10,000. The pipeline exists once it is found.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;d like to use this technique inside a script, you will need to make sure Stop-Pipeline does not stop your entire script. You can do that by embedding the pipeline inside a dummy loop:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="var"&gt;$result&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; { &lt;br /&gt;&lt;span class="verbnoun"&gt;Get-EventLog&lt;/span&gt; Application | &lt;span class="verbnoun"&gt;Stop-Pipeline&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;InstanceID&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; 10000} &lt;br /&gt;} &lt;span class="keyword"&gt;while&lt;/span&gt; (&lt;span class="var"&gt;$false&lt;/span&gt;)&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Stopping+the+%23PowerShell+Pipeline+http%3A%2F%2Fbit.ly%2F9dRKvB" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Stopping+the+%23PowerShell+Pipeline+http%3A%2F%2Fbit.ly%2F9dRKvB" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4682" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Creating Large Dummy Files With .NET</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/11/creating-large-dummy-files-with-net.aspx" /><id>/cs/blogs/tips/archive/2010/03/11/creating-large-dummy-files-with-net.aspx</id><published>2010-03-11T14:00:00Z</published><updated>2010-03-11T14:00:00Z</updated><content type="html">&lt;p&gt;You can always resort to the underlying .NET framework whenever the functionality you need isn&amp;#39;t available through a cmdlet. &lt;/p&gt;
&lt;p&gt;The following code is a very fast way to generate really large test files:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="var"&gt;$path&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="string"&gt;&amp;quot;$env:temp\testfile.txt&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="var"&gt;$file&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; [&lt;span class="namespace"&gt;io.file&lt;/span&gt;]::&lt;span class="method"&gt;Create&lt;/span&gt;(&lt;span class="var"&gt;$path&lt;/span&gt;)&lt;br /&gt;&lt;span class="var"&gt;$file&lt;/span&gt;.&lt;span class="method"&gt;SetLength&lt;/span&gt;(1gb)&lt;br /&gt;&lt;span class="var"&gt;$file&lt;/span&gt;.&lt;span class="method"&gt;Close&lt;/span&gt;()&lt;br /&gt;&lt;span class="verbnoun"&gt;Get-Item&lt;/span&gt; &lt;span class="var"&gt;$path&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Large+Files+with+.NET+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FbYmRZw" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Large+Files+with+.NET+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FbYmRZw" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4681" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Creating Large Dummy Files</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/10/creating-large-dummy-files.aspx" /><id>/cs/blogs/tips/archive/2010/03/10/creating-large-dummy-files.aspx</id><published>2010-03-10T14:00:00Z</published><updated>2010-03-10T14:00:00Z</updated><content type="html">&lt;p&gt;Sometimes, it is more efficient to use existing console tools rather than PowerShell cmdlets. For example here is a way to create a large file for load tests:&lt;/p&gt;
&lt;div class="pscode"&gt;fsutil file createnew &lt;span class="var"&gt;$env:temp&lt;/span&gt;\&lt;span class="namespace"&gt;dummy.bin&lt;/span&gt; (1gb)&lt;/div&gt;
&lt;p&gt;However, you should note that fsutil requires admin privileges.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Large+Files+with+fsutil+from+%23PowerShell+http%3A%2F%2Fbit.ly%2F9NCO1L" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Large+Files+with+fsutil+from+%23PowerShell+http%3A%2F%2Fbit.ly%2F9NCO1L" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4680" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Running PowerShell Scripts as Scheduled Task</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/09/running-powershell-scripts-as-scheduled-task.aspx" /><id>/cs/blogs/tips/archive/2010/03/09/running-powershell-scripts-as-scheduled-task.aspx</id><published>2010-03-09T14:00:00Z</published><updated>2010-03-09T14:00:00Z</updated><content type="html">&lt;p&gt;If you have jobs that need to execute regularly, you can manage them with a PowerShell script and make it a scheduled task:&lt;/p&gt;
&lt;div class="pscode"&gt;schtasks &lt;span class="op"&gt;/&lt;/span&gt;CREATE &lt;span class="op"&gt;/&lt;/span&gt;TN CheckHealthScript &lt;span class="op"&gt;/&lt;/span&gt;TR &lt;span class="string"&gt;&amp;quot;powershell.exe `&lt;/span&gt;&lt;br /&gt;&lt;span class="string"&gt;  -noprofile -executionpolicy Unrestricted `&lt;/span&gt;&lt;br /&gt;&lt;span class="string"&gt;  -file %public%\checkhealth.ps1&amp;quot;&lt;/span&gt; &lt;span class="op"&gt;/&lt;/span&gt;IT &lt;span class="op"&gt;/&lt;/span&gt;RL HIGHEST &lt;span class="op"&gt;/&lt;/span&gt;SC DAILY&lt;/div&gt;
&lt;p&gt;To remove the scheduled task, specify the name you assigned:&lt;/p&gt;
&lt;div class="pscode"&gt;schtasks &lt;span class="op"&gt;/&lt;/span&gt;DELETE &lt;span class="op"&gt;/&lt;/span&gt;TN CheckHealthScript&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Running+%23PowerShell+Scripts+as+Scheduled+Task+http%3A%2F%2Fbit.ly%2F9jzFFi" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Running+%23PowerShell+Scripts+as+Scheduled+Task+http%3A%2F%2Fbit.ly%2F9jzFFi" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4679" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Launching a PowerShell Script Externally</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/08/launching-a-powershell-script-externally.aspx" /><id>/cs/blogs/tips/archive/2010/03/08/launching-a-powershell-script-externally.aspx</id><published>2010-03-08T14:00:00Z</published><updated>2010-03-08T14:00:00Z</updated><content type="html">&lt;p&gt;To launch a PowerShell script outside of the PowerShell console (i.e. as scheduled task or as a link), prepend the script path with this:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="namespace"&gt;Powershell.exe&lt;/span&gt; &lt;span class="modifier"&gt;-noprofile&lt;/span&gt; &lt;span class="modifier"&gt;-executionpolicy&lt;/span&gt; Bypass c:\&lt;span class="namespace"&gt;pathtoscript.ps1&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;As you can see, in v.2 Microsoft added an -executionPolicy parameter, which allows you to override whatever execution policy is set by default. However, your call cannot override this setting if the execution policy was defined by a group policy.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Launching+a+%23PowerShell+Script+Externally+http%3A%2F%2Fbit.ly%2FafKTdl" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Launching+a+%23PowerShell+Script+Externally+http%3A%2F%2Fbit.ly%2FafKTdl" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4678" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Accessing Profile Scripts</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/05/accessing-profile-scripts.aspx" /><id>/cs/blogs/tips/archive/2010/03/05/accessing-profile-scripts.aspx</id><published>2010-03-05T14:00:00Z</published><updated>2010-03-05T14:00:00Z</updated><content type="html">&lt;p&gt;Profile scripts are executed automatically when PowerShell starts. The paths to these scripts can be found in $profile:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="var"&gt;$profile&lt;/span&gt; | gm &lt;span class="op"&gt;*&lt;/span&gt;Host&lt;span class="op"&gt;*&lt;/span&gt; | &lt;span class="op"&gt;%&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;Name&lt;/span&gt; } | &lt;span class="op"&gt;%&lt;/span&gt; {&lt;br /&gt;  &lt;span class="var"&gt;$rv&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; @{}; &lt;span class="var"&gt;$rv&lt;/span&gt;.&lt;span class="method"&gt;Name&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="var"&gt;$_&lt;/span&gt;&lt;br /&gt;  &lt;span class="var"&gt;$rv&lt;/span&gt;.&lt;span class="method"&gt;Path&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="var"&gt;$profile&lt;/span&gt;.&lt;span class="var"&gt;$_&lt;/span&gt;&lt;br /&gt;  &lt;span class="var"&gt;$rv&lt;/span&gt;.&lt;span class="method"&gt;Exists&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt; (&lt;span class="verbnoun"&gt;Test-Path&lt;/span&gt; &lt;span class="var"&gt;$profile&lt;/span&gt;.&lt;span class="var"&gt;$_&lt;/span&gt;)&lt;br /&gt;  &lt;span class="verbnoun"&gt;New-Object&lt;/span&gt; PSObject &lt;span class="modifier"&gt;-Property&lt;/span&gt; &lt;span class="var"&gt;$rv&lt;/span&gt; &lt;br /&gt;} | &lt;span class="verbnoun"&gt;Format-Table&lt;/span&gt; &lt;span class="modifier"&gt;-AutoSize&lt;/span&gt;&lt;/div&gt;
&lt;div class="psoutput"&gt;Name                    Path               Exists&lt;br /&gt;----                    ----               ------&lt;br /&gt;AllUsersAllHosts        C:\Windows\...ps1  True&lt;br /&gt;AllUsersCurrentHosts    C:\Windows\...ps1  False&lt;br /&gt;CurrentUserAllHosts     C:\Users\...ps1    True&lt;br /&gt;CurrentUserCurrentHost  C:\Users\...ps1    True&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Accessing+%23PowerShell+Profile+Scripts+http%3A%2F%2Fbit.ly%2F9eZYgc" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Accessing+%23PowerShell+Profile+Scripts+http%3A%2F%2Fbit.ly%2F9eZYgc" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4677" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Listing Execution Policies</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/04/listing-execution-policies.aspx" /><id>/cs/blogs/tips/archive/2010/03/04/listing-execution-policies.aspx</id><published>2010-03-04T14:00:00Z</published><updated>2010-03-04T14:00:00Z</updated><content type="html">&lt;p&gt;In PowerShell v.2, there are multiple execution policies. You should use this to view and check the settings:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-ExecutionPolicy&lt;/span&gt; &lt;span class="modifier"&gt;-List&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Listing+%23PowerShell+Execution+Policies+http%3A%2F%2Fbit.ly%2FcFdbO2" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Listing+%23PowerShell+Execution+Policies+http%3A%2F%2Fbit.ly%2FcFdbO2" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4676" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Closing a Program Gracefully</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/03/closing-a-program-gracefully.aspx" /><id>/cs/blogs/tips/archive/2010/03/03/closing-a-program-gracefully.aspx</id><published>2010-03-03T14:00:00Z</published><updated>2010-03-03T14:00:00Z</updated><content type="html">&lt;p&gt;When you use Stop-Process to kill a program, it will  stop instantaneously. The user will get no chance to save unsaved documents:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Process&lt;/span&gt; Notepad | &lt;span class="verbnoun"&gt;Stop-Process&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Try a more graceful way by using  an internal .NET method, which then acts as if someone closed the program window. If the content has not been saved, a dialog opens and asks for a choice:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Process&lt;/span&gt; Notepad | &lt;br /&gt;  &lt;span class="verbnoun"&gt;Foreach-Object&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;CloseMainWindow&lt;/span&gt;() | &lt;span class="verbnoun"&gt;Out-Null&lt;/span&gt; }&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Closing+a+Program+Gracefully+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FdbuAVr" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Closing+a+Program+Gracefully+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FdbuAVr" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4675" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Stopping a Program Whenever You Feel Like It</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/02/stopping-a-program-whenever-you-feel-like-it.aspx" /><id>/cs/blogs/tips/archive/2010/03/02/stopping-a-program-whenever-you-feel-like-it.aspx</id><published>2010-03-02T14:00:00Z</published><updated>2010-03-02T14:00:00Z</updated><content type="html">&lt;p&gt;When you launch a program using Start-Process with -passThru, you will get back the process object representing the started program. You can then use this object later to kill the program whenever necessary.&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="var"&gt;$notepad&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="verbnoun"&gt;Start-Process&lt;/span&gt; notepad &lt;span class="modifier"&gt;-passthru&lt;/span&gt;&lt;br /&gt;&lt;span class="verbnoun"&gt;Start-Sleep&lt;/span&gt; 2&lt;br /&gt;&lt;span class="verbnoun"&gt;Stop-Process&lt;/span&gt; &lt;span class="modifier"&gt;-inputObject&lt;/span&gt; &lt;span class="var"&gt;$notepad&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4674" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Use CHOICE to Prompt for Input</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/03/01/use-choice-to-prompt-for-input.aspx" /><id>/cs/blogs/tips/archive/2010/03/01/use-choice-to-prompt-for-input.aspx</id><published>2010-03-01T14:00:00Z</published><updated>2010-03-01T14:00:00Z</updated><content type="html">&lt;p&gt;PowerShell can run native console applications, which  can be very helpful. For example, you should take a closer look at CHOICE.EXE, which will  prompt you for information:&lt;/p&gt;
&lt;div class="pscode"&gt;Choice &lt;span class="op"&gt;/&lt;/span&gt;N &lt;span class="op"&gt;/&lt;/span&gt;C:123 &lt;span class="op"&gt;/&lt;/span&gt;M &lt;span class="string"&gt;&amp;quot;Enter a number between 1 and 3!&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="string"&gt;&amp;quot;Your choice: $LASTEXITCODE&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;This will get you a simple Y/N prompt:&lt;/p&gt;
&lt;div class="pscode"&gt;Choice &lt;span class="op"&gt;/&lt;/span&gt;N &lt;span class="op"&gt;/&lt;/span&gt;C:YN &lt;span class="op"&gt;/&lt;/span&gt;M &lt;span class="string"&gt;&amp;quot;Do you agree (Y/N)?&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="string"&gt;&amp;quot;Your answer: $LASTEXITCODE&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Use+CHOICE+to+Prompt+for+Input+in+%23PowerShell+http%3A%2F%2Fbit.ly%2FcBasGI" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Use+CHOICE+to+Prompt+for+Input+in+%23PowerShell+http%3A%2F%2Fbit.ly%2FcBasGI" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4673" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Launching Programs Maximized</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/02/26/launching-programs-maximized.aspx" /><id>/cs/blogs/tips/archive/2010/02/26/launching-programs-maximized.aspx</id><published>2010-02-26T14:00:00Z</published><updated>2010-02-26T14:00:00Z</updated><content type="html">&lt;p&gt;Start-Process has a parameter called -WindowStyle. With it, you can control the window size of the application you launch. You should use this line to launch notepad maximized:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Start-Process&lt;/span&gt; notepad &lt;span class="modifier"&gt;-WindowStyle&lt;/span&gt; Maximized&lt;/div&gt;
&lt;p&gt;Supported arguments are Maximized, Minimized, Normal, and Hidden. Be sure to watch out with Hidden! You should only use it for programs that do not require user interaction.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Launching%20Programs%20Maximized%20from%20#PowerShell%20http://bit.ly/9f9voL" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Launching%20Programs%20Maximized%20from%20#PowerShell%20http://bit.ly/9f9voL" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4672" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Wait for Programs</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/02/25/wait-for-programs.aspx" /><id>/cs/blogs/tips/archive/2010/02/25/wait-for-programs.aspx</id><published>2010-02-25T14:00:00Z</published><updated>2010-02-25T14:00:00Z</updated><content type="html">&lt;p&gt;PowerShell launches Windows applications asynchronously. It only waits for the console application so you should use -wait if you want to launch a Windows application and wait for it until it finishes:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Start-Process&lt;/span&gt; notepad &lt;span class="modifier"&gt;-wait&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Wait+for+Programs+Launched+from+%23PowerShell+http%3A%2F%2Fbit.ly%2F9a7KfV" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Wait+for+Programs+Launched+from+%23PowerShell+http%3A%2F%2Fbit.ly%2F9a7KfV" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4671" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Open Current Folder in Your Explorer</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/02/24/open-current-folder-in-your-explorer.aspx" /><id>/cs/blogs/tips/archive/2010/02/24/open-current-folder-in-your-explorer.aspx</id><published>2010-02-24T14:00:00Z</published><updated>2010-02-24T14:00:00Z</updated><content type="html">&lt;p&gt;If you are stuck in the console and would like to move over to the Explorer GUI, the next line opens your current folder in an Explorer window:&lt;/p&gt;
&lt;div class="pscode"&gt;explorer .&lt;/div&gt;
&lt;p&gt;Of course, this only works when the current folder is set to a folder in your file system.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Open+Current+Folder+in+Your+Explorer+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FbVtCJ2" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Open+Current+Folder+in+Your+Explorer+from+%23PowerShell+http%3A%2F%2Fbit.ly%2FbVtCJ2" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4670" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry><entry><title>Search for Localized Keywords</title><link rel="alternate" type="text/html" href="/cs/blogs/tips/archive/2010/02/23/search-for-localized-keywords.aspx" /><id>/cs/blogs/tips/archive/2010/02/23/search-for-localized-keywords.aspx</id><published>2010-02-23T14:00:00Z</published><updated>2010-02-23T14:00:00Z</updated><content type="html">&lt;p&gt;Finding the appropriate command for a task is important. With a little trick, PowerShell can help you. Have a look:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; ??(&lt;span class="var"&gt;$keywords&lt;/span&gt;) { &lt;span class="verbnoun"&gt;Get-Help&lt;/span&gt; &lt;span class="op"&gt;*&lt;/span&gt; | &lt;br /&gt;  ? { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;description&lt;/span&gt; &lt;span class="op"&gt;-like&lt;/span&gt; &lt;span class="string"&gt;&amp;quot;*$keywords*&amp;quot;&lt;/span&gt; } | &lt;br /&gt;  &lt;span class="verbnoun"&gt;Select-Object&lt;/span&gt; Name, Synopsis }&lt;/div&gt;
&lt;p&gt;This function called &amp;quot;??&amp;quot; searches Help content for any keyword you specify. Since Help files are localized, you can happily use keywords in your own language (the language your window uses, to be exact). For example, on German systems, you could search for &amp;quot;Drucker&amp;quot; and get back everything related to &amp;quot;printer&amp;quot;:&lt;/p&gt;
&lt;div class="pscode"&gt;?? drucker&lt;br /&gt;?? zufall&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Search+for+Localized+%23PowerShell+Keywords+http%3A%2F%2Fbit.ly%2FaPALnE" target="twitter"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a href="http://twitter.com/home/?status=RT+%40PowerTip+Search+for+Localized+%23PowerShell+Keywords+http%3A%2F%2Fbit.ly%2FaPALnE" target="twitter"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=4669" width="1" height="1"&gt;</content><author><name>ps1</name><uri>http://powershell.com/cs/members/ps1/default.aspx</uri></author></entry></feed>