<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>..::\\ www.christiano.ch //::.. &#187; PowerShell</title>
	<atom:link href="http://www.christiano.ch/wordpress/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christiano.ch/wordpress</link>
	<description>christiano.ch blog - personal knowledge base, news, memoires et cetera</description>
	<lastBuildDate>Fri, 06 Jan 2012 15:28:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>Export and Import Mailbox data to a PST file on Exchange Server 2007</title>
		<link>http://www.christiano.ch/wordpress/2012/01/05/export-and-import-mailbox-data-to-a-pst-file-on-exchange-server-2007/</link>
		<comments>http://www.christiano.ch/wordpress/2012/01/05/export-and-import-mailbox-data-to-a-pst-file-on-exchange-server-2007/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 06:49:07 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Exchange Server]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Export]]></category>
		<category><![CDATA[Import]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PST]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2012/01/05/export-and-import-mailbox-data-to-a-pst-file-on-exchange-server-2007/</guid>
		<description><![CDATA[This procedure describes how to export all mailboxes from one Exchange Server to a PST files and how to import the PST files to another Exchange Server in a different domain. Before you begin make sure that: You have a &#8230; <a href="http://www.christiano.ch/wordpress/2012/01/05/export-and-import-mailbox-data-to-a-pst-file-on-exchange-server-2007/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This procedure describes how to export all mailboxes from one Exchange Server to a PST files and how to import the PST files to another Exchange Server in a different domain. Before you begin make sure that: </p>
<p><span id="more-1270"></span>
<ul>
<li>You have a computer that has Outlook 2003 (SP2) or 2007, Exchange 2007 Management Tools (32-bit version), PowerShell and .NET Framework installed </li>
<li>Logon with an account that has Exchange Server Administrator and Local Administrator rights </li>
<li>You have full access to the users’ mailbox on both servers. See the note below on how to do it. </li>
</ul>
<p>&#160;</p>
<ul>
<ol>
<li>Start the Exchange Management Shell and type the following:<strong><em>[PS] C:\&gt;Get-Mailbox –Database “&lt;Exchange Server FQDN&gt;\&lt;Database Name&gt;” | Export-Mailbox –PSTFolderPath C:\PSTFiles</em></strong> to export all users mailbox to a PST file. Press A for Yes to All. Depending on the size of your database, the export procedure could take a long time to complete. </li>
<li>Now the mailboxes are exported to the PST files, make sure that the PST file name matches the alias of the users’ account in the other domain. </li>
<li>Next, import the PST files to the other Exchange Server by typing the following: <strong><em>[PS] C:\&gt;Get-Mailbox –Database “&lt;Exchange Server FQDN&gt;\&lt;Database Name&gt;” | Import-Mailbox –PSTFolderPath C:\PSTFiles</em></strong> and press A for Yes for All. Wait until the import operation completes.</li>
</ol>
<p><strong><em>Note:</em></strong>      <br />To grant the Administrator Full Access rights on the database type the following command:      <br /><strong><em>[PS] C:\&gt;Get-Mailbox -Database “&lt;Exchange Server FQDN&gt;\&lt;Database Name&gt;” | Add-ADPermission -User Administrator -AccessRights GenericAll</em></strong></p>
</ul>
<ol></ol>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Export+and+Import+Mailbox+data+to+a+PST+file+on+Exchange+Server+2007+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1270" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Export+and+Import+Mailbox+data+to+a+PST+file+on+Exchange+Server+2007+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1270" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2012/01/05/export-and-import-mailbox-data-to-a-pst-file-on-exchange-server-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding process that locks a DLL</title>
		<link>http://www.christiano.ch/wordpress/2011/09/04/finding-process-that-locks-a-dll/</link>
		<comments>http://www.christiano.ch/wordpress/2011/09/04/finding-process-that-locks-a-dll/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 06:15:08 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[CMD / Batch]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Tips n'Tricks]]></category>
		<category><![CDATA[Windows General]]></category>
		<category><![CDATA[DLL]]></category>
		<category><![CDATA[Tasklist]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2011/09/04/finding-process-that-locks-a-dll/</guid>
		<description><![CDATA[You want to replace a dll on a system, but you get access denied, although you’re admin, have the necessary rights.. so which process is locking the particular file/library. I know, there is handles.exe from Sysinternal Suite, and plenty other &#8230; <a href="http://www.christiano.ch/wordpress/2011/09/04/finding-process-that-locks-a-dll/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="2" width="675">
<tbody>
<tr>
<td valign="top" width="557">You want to replace a dll on a system, but you get access denied, although you’re admin, have the necessary rights.. so which process is locking the particular file/library. I know, there is handles.exe from Sysinternal Suite, and plenty other tools that do the trick.But, you don’t need third-party tools to get the answer, just use tasklist.exe or PowerShell.</td>
<td valign="top" width="117">&nbsp;</td>
</tr>
</tbody>
</table>
<p><span id="more-1254"></span>
<p>Windows command line:</p>
<pre>C:\&gt; tasklist /FI "modules eq vstoee.dll"</pre>
<p>PowerShell
<pre>PS C:\&gt; Get-Process | ? { $_.Modules -like "*(vstoee.dll)*" }</pre>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Finding+process+that+locks+a+DLL+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1254" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Finding+process+that+locks+a+DLL+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1254" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2011/09/04/finding-process-that-locks-a-dll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting registry last write time with PowerShell</title>
		<link>http://www.christiano.ch/wordpress/2011/07/16/getting-registry-last-write-time-with-powershell/</link>
		<comments>http://www.christiano.ch/wordpress/2011/07/16/getting-registry-last-write-time-with-powershell/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 16:02:12 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2011/07/16/getting-registry-last-write-time-with-powershell/</guid>
		<description><![CDATA[All registry keys have a value associated with called the Last Write Time. This is analogous to the last modification time for a file. When ever the registry key or one if its values has been created, modified, or deleted &#8230; <a href="http://www.christiano.ch/wordpress/2011/07/16/getting-registry-last-write-time-with-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>All registry keys have a value associated with called the Last Write Time. This is analogous to the last modification time for a file. When ever the registry key or one if its values has been created, modified, or deleted the value is updated to the current local system time. Unfortunately, there is no Last Write Time associated with a registry value, but it can be infered from the Last Write Time of the key.</p>
<p>Here is a PowerShell script to read the Last Write Time for a registry key.</p>
<p>Usage:</p>
<pre>Get-RegKeyLastWriteTime.ps1 &lt;Key&gt; &lt;SubKey&gt;</pre>
<p><span id="more-1242"></span>
<p>Example:</p>
<pre>Get-RegKeyLastWriteTime.ps1 HKLM SOFTWARE\Microsoft\Windows\CurrentVersion</pre>
<p>Output:</p>
<pre>Key                         LastWriteTime
—-                         ——————-
AdminDebug                  10/28/2009 7:50:51 PM
App Management              7/14/2009 4:41:12 AM
App Paths                   1/22/2010 2:07:18 PM
Applets                     7/14/2009 4:41:12 AM
Audio                       7/14/2009 4:41:12 AM
Authentication              7/14/2009 4:41:12 AM
BitLocker                   7/14/2009 4:41:12 AM
...</pre>
<p>Get-RegKeyLastWriteTime.ps1 Script:</p>
<pre>param (	[string] $Key, [string] $SubKey )

switch ($Key) {
    &quot;HKCR&quot; { $searchKey = 0x80000000} #HK Classes Root
    &quot;HKCU&quot; { $searchKey = 0x80000001} #HK Current User
    &quot;HKLM&quot; { $searchKey = 0x80000002} #HK Local Machine
    &quot;HKU&quot;  { $searchKey = 0x80000003} #HK Users
    &quot;HKCC&quot; { $searchKey = 0x80000005} #HK Current Config
    default {
        #throw &quot;Invalid Key. Use one of the following options HKCR, HKCU, HKLM, HKU, HKCC&quot;
    }
}

$KEYQUERYVALUE = 0x1
$KEYREAD = 0x19
$KEYALLACCESS = 0x3F

$sig1 = @'
[DllImport(&quot;advapi32.dll&quot;, CharSet = CharSet.Auto)]
  public static extern int RegOpenKeyEx(
    int hKey,
    string subKey,
    int ulOptions,
    int samDesired,
    out int hkResult);
'@
$type1 = Add-Type -MemberDefinition $sig1 -Name Win32Utils `
    -Namespace RegOpenKeyEx -Using System.Text -PassThru

$sig2 = @'
[DllImport(&quot;advapi32.dll&quot;, EntryPoint = &quot;RegEnumKeyEx&quot;)]
extern public static int RegEnumKeyEx(
    int hkey,
    int index,
    StringBuilder lpName,
    ref int lpcbName,
    int reserved,
    int lpClass,
    int lpcbClass,
    out long lpftLastWriteTime);
'@
$type2 = Add-Type -MemberDefinition $sig2 -Name Win32Utils `
    -Namespace RegEnumKeyEx -Using System.Text -PassThru

$sig3 = @'
[DllImport(&quot;advapi32.dll&quot;, SetLastError=true)]
public static extern int RegCloseKey(
    int hKey);
'@
$type3 = Add-Type -MemberDefinition $sig3 -Name Win32Utils `
    -Namespace RegCloseKey -Using System.Text -PassThru

$hKey = new-object int
$result = $type1::RegOpenKeyEx($searchKey, $SubKey, 0, $KEYREAD, [ref] $hKey)

#initialize variables
$builder = New-Object System.Text.StringBuilder 1024
$index = 0
$length = [int] 1024
$time = New-Object Long

#234 means more info, 0 means success. Either way, keep reading
while ( 0,234 -contains $type2::RegEnumKeyEx($hKey, $index++, `
    $builder, [ref] $length, $null, $null, $null, [ref] $time) )
{
    #create output object
    $o = &quot;&quot; | Select Key, LastWriteTime
    $o.Key = $builder.ToString()
    $o.LastWriteTime = (Get-Date $time).AddYears(1600)
    $o

    #reinitialize for next time through the loop
    $length = [int] 1024
    $builder = New-Object System.Text.StringBuilder 1024
}

$result = $type3::RegCloseKey($hKey);</pre>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Getting+registry+last+write+time+with+PowerShell+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1242" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Getting+registry+last+write+time+with+PowerShell+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1242" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2011/07/16/getting-registry-last-write-time-with-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scan IP range using ping</title>
		<link>http://www.christiano.ch/wordpress/2011/07/16/scan-ip-range-using-ping/</link>
		<comments>http://www.christiano.ch/wordpress/2011/07/16/scan-ip-range-using-ping/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 15:35:44 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[CMD / Batch]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmd]]></category>
		<category><![CDATA[IPScan]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2011/07/16/scan-ip-range-using-ping/</guid>
		<description><![CDATA[IP scanner for the poor ones Just open up a cmd.exe and change the ip range.. C:\&#62;FOR /L %x in (1,1,255) do ping -n 1 192.168.2.%x &#124; find /I &#34;reply&#34; &#62;&#62; c:\temp\pingresult.txt The above command uses a FOR loop to &#8230; <a href="http://www.christiano.ch/wordpress/2011/07/16/scan-ip-range-using-ping/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>IP scanner for the poor ones <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Zwinkerndes Smiley" src="http://www.christiano.ch/wordpress/wp-content/uploads/2011/07/wlEmoticon-winkingsmile.png" /></p>
<p>Just open up a cmd.exe and change the ip range..</p>
<blockquote><p>C:\&gt;FOR /L %x in (1,1,255) do ping -n 1 192.168.2.%x | find /I &quot;reply&quot; &gt;&gt; c:\temp\pingresult.txt</p>
</blockquote>
<p>The above command uses a FOR loop to ping each device and looks for &quot;Reply&quot; in the output. If there is a &quot;Reply&quot; then the host is up.. Results will be written to C:\temp\pingresults.txt</p>
<p>Or the PowerShell version: </p>
<blockquote><p>C:\&gt; 1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send(&quot;192.168.2.$_&quot;) } | where-object {$_.Status -eq &quot;success&quot;} | select Address</p>
</blockquote>
<p><span id="more-1240"></span>
<p>Address    <br />&#8212;&#8212;-     <br />192.168.2.1     <br />192.168.2.5     <br />192.168.2.10     <br />192.168.2.11     <br />192.168.2.12</p>
<p>At first glance the results are very similar and you would think, &quot;Why all the extra typing? The second command is 2.5 times longer!&quot; The big difference between the standard windows command line and powershell is that the latter uses objects, which gives a lot of power&#8230;in our shell. Not let&#8217;s see how it works&#8230;</p>
<p>In the above command the range operator (..) generates a list of the numbers 1 through 255. The cool thing is you don&#8217;t have to use just a single range, you can string them together like this (1..5),7,(9..10) which would give you the numbers 1-10 skipping 6 and 8.</p>
<blockquote><p>foreach-object { (new-object System.Net.Networkinformation.Ping).Send(&quot;10.10.10.$_&quot;) }</p>
</blockquote>
<p>The foreach-object takes the numbers fed into the pipeline and operates on them one at a time. First, it creates a new ping object and then calls the send method. The parameter given to the send method is a string concatenation of 10.10.10. and the number from $_, which is the &quot;current pipeline object.&quot; The $_ variable in our example will contain the numbers 1-255.</p>
<blockquote><p>where-object {$_.Status -eq &quot;success&quot;}</p>
</blockquote>
<p>The output of the send method is the PingReply object which contains a status. We can filter the results only successful pings reply objects will be sent further down the pipeline.</p>
<blockquote><p>Select Address      <br />Finally, all we care about is the address so that is the only piece we have displayed.</p>
</blockquote>
<p>Now that we know how it works, let&#8217;s pimp out our powershell version.</p>
<p>First, we don&#8217;t have to just use a contiguous set of numbers. If we wanted to scan all ip address before 10.10.10.100, after 10.10.10.200 and 10.10.10.155 we could use this:    <br />(1..99),(200..255),155 | foreach-object &#8230;.     <br />We can use the results to feed into other commands. You can ping sweep an entire subnet and have it automatically do an nslookup, attempt to list the contents of the c$ share, and tell you that you are doing a good job (a little positive reinforcement never hurts).</p>
<blockquote><p>PS C:\&gt;1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send(&quot;10.10.10.$_&quot;) } | where-object {$_.Status -eq &quot;success&quot;} | foreach-object { nslookup $_; gci &quot;\\$($_.Address)\c$&quot;; echo &quot;Good Job&quot; }</p>
</blockquote>
<p>The ping sweep can be sped up by setting a timeout value (in milliseconds). In the example below we set the timeout value to 100ms.</p>
<blockquote><p>&#8230; (new-object System.Net.Networkinformation.Ping).Send(&quot;10.10.10.$_&quot;, 100) &#8230;</p>
</blockquote>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Scan+IP+range+using+ping+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1240" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Scan+IP+range+using+ping+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D1240" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2011/07/16/scan-ip-range-using-ping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: About SessionConfiguration and how to change them</title>
		<link>http://www.christiano.ch/wordpress/2010/04/24/powershell-about-sessionconfiguration-and-how-to-change-them/</link>
		<comments>http://www.christiano.ch/wordpress/2010/04/24/powershell-about-sessionconfiguration-and-how-to-change-them/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:18:31 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/?p=929</guid>
		<description><![CDATA[Remote Access Without Admin Privileges In PowerShell v.2, remote access is available only to users who hold local administrator privileges. So, even if you do have appropriate remote access to a machine, , you cannot remotely access the system if &#8230; <a href="http://www.christiano.ch/wordpress/2010/04/24/powershell-about-sessionconfiguration-and-how-to-change-them/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Remote Access Without Admin Privileges</strong></p>
<p>In PowerShell v.2, remote access is available only to users who hold local administrator privileges. So, even if you do have appropriate remote access to a machine, , you cannot remotely access the system if you are not an Admin. This is not a technical limitation, though, just a safe default. You should use this line to change it :</p>
<p><strong>Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI</strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+About+SessionConfiguration+and+how+to+change+them+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D929" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+About+SessionConfiguration+and+how+to+change+them+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D929" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/04/24/powershell-about-sessionconfiguration-and-how-to-change-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Display almost anything in a graphical GridView</title>
		<link>http://www.christiano.ch/wordpress/2010/04/24/powershell-display-almost-anything-in-a-graphical-gridview/</link>
		<comments>http://www.christiano.ch/wordpress/2010/04/24/powershell-display-almost-anything-in-a-graphical-gridview/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:15:48 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[No Category]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/?p=927</guid>
		<description><![CDATA[Out-GridView Dirty Tricks Out-Gridview is a new cmdlet in PowerShell v.2 which allows you to output objects to a &#8220;mini&#8221; excel sheet like this: Get-Process &#124; Out-GridView However, this only works if .NET Framework 3.51 is installed. While PowerShell requires &#8230; <a href="http://www.christiano.ch/wordpress/2010/04/24/powershell-display-almost-anything-in-a-graphical-gridview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Out-GridView Dirty Tricks</p>
<p>Out-Gridview is a new cmdlet in PowerShell v.2 which allows you to output objects to a &#8220;mini&#8221; excel sheet like this:</p>
<p><strong>Get-Process | Out-GridView</strong></p>
<p>However, this only works if .NET Framework 3.51 is installed. While PowerShell requires just .NET 2.0, both Out-GridView and ISE-Editor require 3.51 because of their WPF graphical output.</p>
<p>Out-Gridview will display the same columns you would have seen when you output the objects to the console. You should clone the object first to see all object properties in your gridview:</p>
<p><strong>Get-Process | Select-Object * | Out-Gridview</strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Display+almost+anything+in+a+graphical+GridView+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D927" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Display+almost+anything+in+a+graphical+GridView+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D927" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/04/24/powershell-display-almost-anything-in-a-graphical-gridview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Create a temporary filename</title>
		<link>http://www.christiano.ch/wordpress/2010/04/24/powershell-create-a-temporary-filename/</link>
		<comments>http://www.christiano.ch/wordpress/2010/04/24/powershell-create-a-temporary-filename/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:13:18 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[No Category]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/?p=925</guid>
		<description><![CDATA[Thanks to Get-Date, you can easily create unique temporary file names with a timestamp: (Get-Date -format &#8216;yyyy-MM-dd hh-mm-ss&#8217;) + &#8216;.tmp&#8217; Tweet This Post]]></description>
			<content:encoded><![CDATA[<p>Thanks to Get-Date, you can easily create unique temporary file names with a timestamp:</p>
<p><strong>(Get-Date -format &#8216;yyyy-MM-dd hh-mm-ss&#8217;) + &#8216;.tmp&#8217;</strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Create+a+temporary+filename+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D925" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Create+a+temporary+filename+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D925" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/04/24/powershell-create-a-temporary-filename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Generate PC Lists using Foreach-Object and -f Operator</title>
		<link>http://www.christiano.ch/wordpress/2010/04/24/powershell-generate-pc-lists-using-foreach-object-and-f-operator/</link>
		<comments>http://www.christiano.ch/wordpress/2010/04/24/powershell-generate-pc-lists-using-foreach-object-and-f-operator/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:10:36 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/?p=921</guid>
		<description><![CDATA[Generate PC Lists One easy way of creating lists of PC names or IP address ranges etc is a simple pipeline like this: 1..40 &#124; Foreach-Object { &#8216;PC-W7-A{0:000}&#8217; -f $_ } Use the -f operator to format the number. In &#8230; <a href="http://www.christiano.ch/wordpress/2010/04/24/powershell-generate-pc-lists-using-foreach-object-and-f-operator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Generate PC Lists</p>
<p>One easy way of creating lists of PC names or IP address ranges etc is a simple pipeline like this:</p>
<p><strong>1..40 | Foreach-Object { &#8216;PC-W7-A{0:000}&#8217; -f $_ }</strong></p>
<p>Use the -f operator to format the number. In this example, it will always be three-digit.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Generate+PC+Lists+using+Foreach-Object+and+-f+Operator+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D921" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Generate+PC+Lists+using+Foreach-Object+and+-f+Operator+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D921" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/04/24/powershell-generate-pc-lists-using-foreach-object-and-f-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Sort-Object</title>
		<link>http://www.christiano.ch/wordpress/2010/04/24/powershell-sort-object/</link>
		<comments>http://www.christiano.ch/wordpress/2010/04/24/powershell-sort-object/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:08:19 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/?p=919</guid>
		<description><![CDATA[You can use Sort-Object to sort simple variable types. Have a look at the following: &#8216;Tom&#8217;, &#8216;Chris&#8217;, &#8216;Judy&#8217;, &#8216;Alan&#8217; &#124; Sort-Object Input can come from a different command. If you’d like to get seven random lottery numbers, you should try &#8230; <a href="http://www.christiano.ch/wordpress/2010/04/24/powershell-sort-object/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You can use Sort-Object to sort simple variable types. Have a look at the following:</p>
<p><strong>&#8216;Tom&#8217;, &#8216;Chris&#8217;, &#8216;Judy&#8217;, &#8216;Alan&#8217; | Sort-Object<br />
</strong></p>
<p>Input can come from a different command. If you’d like to get seven random lottery numbers, you should try this:</p>
<p><strong>1..49 | Get-Random -Count 7 | Sort-Object</strong></p>
<p>You’ll find that when you feed complex objects into Sort-Object, you should specify the object property you want to sort on (or else Sort-Object will pick one by itself):</p>
<p><strong>Get-ChildItem $env:windir | Sort-Object Length</strong></p>
<p>Here are some more examples:</p>
<p><strong>Get-HotFix | Sort-Object InstalledOn</p>
<p>Get-ComputerRestorePoint | Sort-Object Description</strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Sort-Object+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D919" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Sort-Object+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D919" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/04/24/powershell-sort-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Creating large dummy files with .NET</title>
		<link>http://www.christiano.ch/wordpress/2010/03/13/powershell-creating-large-dummy-files-with-net/</link>
		<comments>http://www.christiano.ch/wordpress/2010/03/13/powershell-creating-large-dummy-files-with-net/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 13:23:02 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2010/03/13/powershell-creating-large-dummy-files-with-net/</guid>
		<description><![CDATA[Ok, this one’s is cool i think. Whenever i needed a large dummy file, i opened up notepad, write ASDFASDFASDFA CTRL-A, CTRL-C, CTRL-V,CTRL-V,CTRL-V,CTRL-V. CTRL-A, CTRL-C, CTRL-V,CTRL-V,CTRL-V,CTRL-V,CTRL-V.. Then i saved the file, opened up a CMD-Shell and wrote copy dummyFile.txt+dummyFile.txt+dummyFile.txt until &#8230; <a href="http://www.christiano.ch/wordpress/2010/03/13/powershell-creating-large-dummy-files-with-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="2" width="675">
<tbody>
<tr>
<td valign="top" width="666">Ok, this one’s is cool i think. Whenever i needed a large dummy file, i opened up notepad, write ASDFASDFASDFA CTRL-A, CTRL-C, CTRL-V,CTRL-V,CTRL-V,CTRL-V. CTRL-A, CTRL-C, CTRL-V,CTRL-V,CTRL-V,CTRL-V,CTRL-V.. Then i saved the file, opened up a CMD-Shell and wrote copy dummyFile.txt+dummyFile.txt+dummyFile.txt until the file was large enough.. ok, there’s fsutil.exe which does the same in a much more efficient manner.. OR, unleash the Power of .NET – no, you don’t have to start programming using Visual Studio, just open up PowerShell.. </td>
<td valign="top" width="10"><a href="http://www.christiano.ch/wordpress/wp-content/uploads/2010/03/Logo_PowerShell1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Logo_PowerShell" border="0" alt="Logo_PowerShell" src="http://www.christiano.ch/wordpress/wp-content/uploads/2010/03/Logo_PowerShell_thumb1.png" width="160" height="125" /></a> </td>
</tr>
</tbody>
</table>
<p> <span id="more-895"></span>
<p>Ok, the goal is to have a 1gb large dummy file .. </p>
<p>first we declare a string variable called file: </p>
<p><code>PS C:\&gt; $file = &quot;$env:temp\dummyFile.txt&quot;</code></p>
<p>no we create on object of type Io.File    <br /><code>PS C:\&gt; $objFile = [io.file]::Create($file)</code></p>
<p>on the object, we call the void SetLength parameterized with 1gb&#160; <br /><code>PS C:\&gt; $objFile.SetLength(1gb)</code></p>
<p>no we call the close method and the file is written    <br /><code>PS C:\&gt; $objFile.Close()</code></p>
<p>using get-item $file we list the file we just created:</p>
<p><code>PS C:\&gt; Get-Item $file </code><code>Directory: C:\Users\&lt;removed&gt;\AppData\Local\Temp </code></p>
<p><code>Mode&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; LastWriteTime&#160;&#160;&#160;&#160; Length Name      <br />----&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -------------&#160;&#160;&#160;&#160; ------ ----       <br />-a---&#160;&#160;&#160;&#160;&#160;&#160;&#160; 13.03.2010&#160;&#160;&#160;&#160; 14:07 1073741824 dummyFile.txt </code></p>
<p><code>PS C:\&gt;</code></p>
<p>Ok, finally we can call an ii (Invoke-Item) to open the Path where the dummyFile resides in Windows Explorer. </p>
<p>To get the Path from a File, we can use Get-ChildItem (Get-ChildItems returns a FileInfo Object/Class). This object has a DirectoryName Property. </p>
<p>We declare an Object $path</p>
<p><code>$path = Get-ChildItem $file</code></p>
<p>Finally we call the mentioned ii (Invoke-Item) to open the path in Windows Explorer.</p>
<p><code>ii $path.DirectoryName</code></p>
<p><strong><em>The complete Script </em></strong></p>
<p><code>$file = &quot;$env:temp\dummyFile.txt&quot;      <br />$objFile = [io.file]::Create($file)       <br />$objFile.SetLength(1gb)       <br />$objFile.Close()       <br />$path = Get-ChildItem $file       <br />ii $path.DirectoryName</code></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Creating+large+dummy+files+with+.NET+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D895" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Creating+large+dummy+files+with+.NET+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D895" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/03/13/powershell-creating-large-dummy-files-with-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

