<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Arul Kumaravel's WebLog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/arulk/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/arulk/feed.xml</link>
    <description>Windows PowerShell technology blog</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:17:34 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Free English version of Windows PowerShell Course book</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/free-english-version-of-windows-powershell-course-book</link>
      <pubDate>Thu, 10 May 2007 13:44:32 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2007/05/10/free-english-version-of-windows-powershell-course-book/</guid>
      <description><![CDATA[Frank Koch has translated his Windows PowerShell course book into English and made it available for...]]></description>
      <content:encoded><![CDATA[<p>Frank Koch has translated his Windows PowerShell course book into English and made it available for free.&nbsp; You can get the free book <a href="https://blogs.technet.com/chitpro-de/archive/2007/05/10/english-version-of-windows-powershell-course-book-available-for-download.aspx">here</a></p> <p>&nbsp;</p> <p>Arul Kumaravel</p> <p>Windows PowerShell Development Manager</p> <p>Microsoft Corporation.</p>]]></content:encoded>
    </item>
    <item>
      <title>How Can I Delete All the Duplicates in a Set of Processes But Keep the Oldest Process?</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/how-can-i-delete-all-the-duplicates-in-a-set-of-processes-but-keep-the-oldest-process</link>
      <pubDate>Tue, 08 May 2007 19:06:38 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2007/05/08/how-can-i-delete-all-the-duplicates-in-a-set-of-processes-but-keep-the-oldest-process/</guid>
      <description><![CDATA[&nbsp; This blog corresponds to the scripting guy column with the same title.&nbsp;&nbsp; I am...]]></description>
      <content:encoded><![CDATA[<p>&nbsp; This blog corresponds to the scripting guy <a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/may07/hey0507.mspx">column</a> with the same title.&nbsp;&nbsp; I am posting the script for doing the same with PowerShell</p> <div> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> $processes = get-wmiobject -query <span style="color: #006080">"Select * from win32_process where name = 'notepad.exe'"</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #0000ff">if</span> ($processes.count <span style="color: #cc6633">-le</span>  2 )</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>   <span style="color: #0000ff">return</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> $datetarget = [DateTime]::Now</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> <span style="color: #0000ff">foreach</span> ($<span style="color: #0000ff">process</span> <span style="color: #0000ff">in</span>  $processes)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>    $dateholder =  $<span style="color: #0000ff">process</span>.CreationDate</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>    $dateholder =  $<span style="color: #0000ff">process</span>.ConvertToDateTime($dateholder)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>    <span style="color: #0000ff">if</span> ( $dateholder <span style="color: #cc6633">-le</span>  $datetarget)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>    {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     $processid =   $<span style="color: #0000ff">process</span>.ProcessID</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         $datetarget  =  $dateholder</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>    }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span> }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span> $processes = get-wmiobject -query <span style="color: #006080">" select * from win32_process where name='notepad.exe' AND processID &lt;&gt; $processid"</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span> <span style="color: #0000ff">foreach</span> ($<span style="color: #0000ff">process</span> <span style="color: #0000ff">in</span> $processes)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span> {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>    $<span style="color: #0000ff">process</span>.Terminate()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span> }</pre></div></div>]]></content:encoded>
    </item>
    <item>
      <title>How Can I Determine the Day of the Week?</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/how-can-i-determine-the-day-of-the-week</link>
      <pubDate>Thu, 30 Nov 2006 09:48:00 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/11/30/how-can-i-determine-the-day-of-the-week/</guid>
      <description><![CDATA[&nbsp;
Hey, PowerShell! I have a script that does certain management tasks based on the day of the...]]></description>
      <content:encoded><![CDATA[<P mce_keep="true">&nbsp;</P>
<P>Hey, PowerShell! I have a script that does certain management tasks based on the day of the week. I know how get the date in a script, but how can I tell whether it’s a Monday or a Tuesday or whatever? 
<P>This is very easy to do with Syste.Datetime class. 
<DIV class=csharpcode><PRE class=alt><SPAN class=kwrd>param</SPAN> ([system.datetime]$date = $([system.datetime]::now))</PRE><PRE>&nbsp;</PRE><PRE class=alt>$dayofweek = $date.DayOfWeek</PRE><PRE>$intday = [int] $date.DayOfWeek</PRE><PRE class=alt>&nbsp;</PRE><PRE>Write-Output <SPAN class=str>"The day of given date is $dayofweek  and numerical value of day is $intday"</SPAN></PRE></DIV>
<STYLE type=text/css>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</STYLE>

<P>Let's see how this script works &nbsp;The script begins by assigning the date from commandline or current date &nbsp;to a variable named $date. 
<P>Next we use the&nbsp;<STRONG>DayofWeek&nbsp;</STRONG>&nbsp;property&nbsp;to determine the day of the week for&nbsp;given date&nbsp; DayofWeek is going to return one of the following value .&nbsp; This is [System.DayOfWeek]&nbsp; enum class values. 
<P>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sunday 
<P>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Monday 
<P>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tuesday 
<P>3&nbsp;&nbsp;&nbsp;&nbsp; Wednesday 
<P>4&nbsp;&nbsp;&nbsp;&nbsp; Thursday 
<P>5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Friday 
<P>6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Saturday </P>
<P>if you want the numerical value of this enum, you can convert it to integer by using the [int] type converter. </P>]]></content:encoded>
    </item>
    <item>
      <title>How Can I Determine the Date for the Friday in a Given Week?</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/how-can-i-determine-the-date-for-the-friday-in-a-given-week</link>
      <pubDate>Wed, 29 Nov 2006 09:27:57 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/11/29/how-can-i-determine-the-date-for-the-friday-in-a-given-week/</guid>
      <description><![CDATA[Hey, Powershell! Given a date, can a script tell me the date that the Friday for that week occurs?...]]></description>
      <content:encoded><![CDATA[<p></p> <p>Hey, Powershell! Given a date, can a script tell me the date that the Friday for that week occurs?  <p>&nbsp;  <p>&nbsp;Here’s a script that – given a date – will report back the date that the Friday of that week falls on:  <p>&nbsp;  <div class="csharpcode"><pre class="alt"><span class="kwrd">param</span> ([system.datetime]$date = $([system.datetime]::now))</pre><pre>&nbsp;</pre><pre class="alt">$intday = [int] $date.DayOfWeek</pre><pre>$intadder =  5 - $intday</pre><pre class="alt">$dateFriday = $date.AddDays( $intadder)</pre><pre>&nbsp;</pre><pre class="alt">Write-Output <span class="str">"The friday of the given date is  $dateFriday"</span></pre></div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>

<div class="csharpcode">&nbsp;</div>
<p>Let's see how this script works &nbsp;The script begins by assigning the date from commandline or current date &nbsp;to a variable named $date. 
<p>&nbsp; 
<p>Next we use the&nbsp;<strong>DayofWeek&nbsp;</strong>&nbsp;property&nbsp;to determine the day of the week for&nbsp;given date&nbsp; DayofWeek is going to return one of the following value 
<p>&nbsp; 
<p>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sunday 
<p>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Monday 
<p>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tuesday 
<p>3&nbsp;&nbsp;&nbsp;&nbsp; Wednesday 
<p>4&nbsp;&nbsp;&nbsp;&nbsp; Thursday 
<p>5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Friday 
<p>6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Saturday 
<p>&nbsp; 
<p>This gives us a value representing the day of the week; What we need to do now is programmatically determine the number of days between this date and the Friday of that week. That’s something we can do with a single line of code: 
<p>$intadder =&nbsp;5 - $intDay 
<p>Confused? Don’t be; this actually makes sense. If you refer to the table you’ll see that Friday has a value of 5. If we take the value for Friday (5) and subtract the value for&nbsp; given date&nbsp;we will get the&nbsp;days to add to get Friday.&nbsp; That’s what we do with this line of code: 
<p>$dateFriday&nbsp;= $date.AddDays($intddder) 
<p>&nbsp; 
<p>System.DateTime is a powerful class that allows you to do date manipulation very easily in PowerShell 
<p>&nbsp; 
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/arulk/WindowsLiveWriter/HowCanIDeterminetheDatefortheFridayinaGi_61B2/powershell_icon%5B1%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/arulk/WindowsLiveWriter/HowCanIDeterminetheDatefortheFridayinaGi_61B2/powershell_icon%5B1%5D.jpg" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="177" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/arulk/WindowsLiveWriter/HowCanIDeterminetheDatefortheFridayinaGi_61B2/powershell_icon.jpg" original-url="https://blogs.msdn.com/blogfiles/arulk/WindowsLiveWriter/HowCanIDeterminetheDatefortheFridayinaGi_61B2/powershell_icon.jpg" width="240" border="0"></a> 
<p>---------------------------------------------------------------------------------------------------------------------- 
<p>Arul Kumaravel 
<p>Development Manager 
<p>Windows PowerShell</p>]]></content:encoded>
    </item>
    <item>
      <title>How Can I Determine the Beginning and Ending Date of the Previous Month?</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/how-can-i-determine-the-beginning-and-ending-date-of-the-previous-month</link>
      <pubDate>Wed, 22 Nov 2006 09:51:49 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/11/22/how-can-i-determine-the-beginning-and-ending-date-of-the-previous-month/</guid>
      <description><![CDATA[Hey, PowerShell! Given a specific date, how can I determine the beginning and ending date of the...]]></description>
      <content:encoded><![CDATA[<p></p> <p><strong>Hey, PowerShell! Given a specific date, how can I determine the beginning and ending date of the previous month? In other words, given 8/11/2005, I need to get back 7/1/2005 and 7/31/2005.</strong> <p>Powershell provides access to .Net framework.&nbsp; We can use .Net framework&nbsp; DateTime class to solve the problem.&nbsp; Let's write a script to solve this. <p>First, we need to get the date for which we need to determine the beginning and ending date of previous month. We can do this using PowerShell Param statement <p>&nbsp; <blockquote> <p><font color="#000000">Param ([System.Datetime] $date = $(get-date))</font></p></blockquote> <p>In the above statement, we are declaring a parameter of type Syste.DateTime.&nbsp; We are also initializing it to current date when no parameter is specified.&nbsp; It works as follows.&nbsp; Let's say that we have saved the above as script file&nbsp; BeginEndPrevMonth.ps1 then <blockquote> <p><font color="#0000ff">.</font><font color="#000000">\BeginEndPrevMonth.ps1&nbsp; 11/18/2006</font></p></blockquote> <p><font color="#000000">will set the $date variable to&nbsp; 11/18/2006.&nbsp; However, if you don't specify the parameter like </font> <blockquote> <p><font color="#000000">.\BeginEndPrevMonth.ps1</font></p></blockquote> <p><font color="#000000">then PowerShell parser will execute the&nbsp; $(get-date)&nbsp; which will get you the current date and time and this value gets assigned to $date. </font> <p><font color="#000000"></font>&nbsp; <p><font color="#000000">Let's move on.&nbsp; Now that we have a date,&nbsp; we need to find the beginning and endind date of the previous month of this date.&nbsp; Let's start the end date.&nbsp; if I have a date like&nbsp; 8/11/2005,&nbsp; then I find out the last date of previous month by subtracting the number of days in the current date.&nbsp; In the example, if I subtract 11 then I will get 7/31/2005.&nbsp; We can accomplish this in the script as follows</font> <p><font color="#000000"></font>&nbsp; <p><font color="#000000">First,&nbsp; determine the number of days in given date</font> <blockquote> <p>$numdays = $date.Day</p></blockquote> <p>Once we have determined the number days,&nbsp; we need to subtract this from the current date to get the last date of previous month.&nbsp; There is no subract method available in&nbsp; Datetime class. however, there is a AddDays method.&nbsp; We can use this method to subtract days by passing in a&nbsp; negative value to add.&nbsp;  <p>&nbsp; <blockquote> <p>$prevmonthlastday = $date.AddDays(- $numdays)</p></blockquote> <p>We are calling&nbsp; AddDays method in DateTime with&nbsp; - $numdays to subtract the number of days.&nbsp; We use the similar logic to subtract the number of days from&nbsp; $prevmonthlastday to determine that last day of previou to previous month and then add 1 day to get the first date. <p>&nbsp; <blockquote> <p>&nbsp; <p>$numdays = $prevmonthlastday.Day<br>$prevmonthfirstday = $prevmonthlastday.AddDays( -$numdays + 1)</p></blockquote> <p>&nbsp; <p>The full script is&nbsp; as follows <p>&nbsp; <blockquote> <p>&nbsp; <p>Param ([system.Datetime] $date = $(get-date))  <p>Write-Output $("The selected date is {0}" -f $date )</p> <p><br>$numdays = $date.Day</p> <p><br>$prevmonthlastday = $date.AddDays(-$numdays) </p> <p>Write-Output $("Last date of previous month of given date is {0}" -f $prevmonthlastday )  <p>$numdays = $prevmonthlastday.Day<br>$prevmonthfirstday = $prevmonthlastday.AddDays( -$numdays + 1)  <p>Write-Output $("First date of previous month of given date is {0}" -f $prevmonthfirstday)</p></blockquote> <p>&nbsp; <p>There you go ,&nbsp; a script to determine beginning and ending date of previous month of a given date. <p>----------------------------------------------------------------------------------------------------------------------------------------------------------------- <p>Arul Kumaravel <p>Development Manager <p>Windows PowerShell <p>&nbsp; <p>&nbsp; <p><font color="#000000"></font>]]></content:encoded>
    </item>
    <item>
      <title>Transcript of Solving Management Problems with Windows PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/transcript-of-solving-management-problems-with-windows-powershell</link>
      <pubDate>Sun, 19 Nov 2006 16:34:00 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/11/19/transcript-of-solving-management-problems-with-windows-powershell/</guid>
      <description><![CDATA[Along with Jeffrey,&nbsp;I presented Solving Management Problems with Windows PowerShell session at...]]></description>
      <content:encoded><![CDATA[<P>Along with Jeffrey,&nbsp;I presented Solving Management Problems with Windows PowerShell session at TechEd Barcelona.&nbsp;&nbsp; Many people asked for the script examples&nbsp; I used during the presentation. Attached zip file contains transcript as well as input files used during presentation.</P>
<P>-------------------------------------------------------------------------------------------------------------------&nbsp;</P>
<P>Arul Kumaravel [MSFT]</P>
<P>Development Manager,</P>
<P>Windows PowerShell,</P>
<P>My PowerShell blog: <A href="https://blogs.msdn.com/arulk" mce_href="https://blogs.msdn.com/arulk">https://blogs.msdn.com/arulk</A></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/01/10/48/53/TechEd.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-01-10-48-53/TechEd.zip">TechEd.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Windows PowerShell 1.0 Launched</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/windows-powershell-1-0-launched</link>
      <pubDate>Tue, 14 Nov 2006 05:04:00 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/11/14/windows-powershell-1-0-launched/</guid>
      <description><![CDATA[I am here at TechED-IT Forum at&nbsp; Barcelona, Spain.&nbsp;&nbsp; Today, in his keynote address...]]></description>
      <content:encoded><![CDATA[<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>I am here at TechED-IT Forum at<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Barcelona, Spain.<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>Today, in his keynote address Bob Muglia, Senior Vice President, Microsoft Corporation, officially launched Windows PowerShell 1.0.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Jeffrey Snover showed an awesome demo of using PowerShell to manage IIS 7<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>in Longhorn<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Server.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT face="Times New Roman">PowerShell has been multiyear effort by many members of Windows PowerShell team.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We would like to take this time to thank all our early adopters and customers who provided us with valuable feedback in shaping up this product. It is with pride that we launch this product.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>PowerShell is ready for primetime to solve management problems one script at a time.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>Reading Attributes of Directory Service Objects</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/reading-attributes-of-directory-service-objects</link>
      <pubDate>Thu, 24 Aug 2006 18:28:09 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/08/24/reading-attributes-of-directory-service-objects/</guid>
      <description><![CDATA[The previous blogs described how to create an OU, a user account, and a group, and set the...]]></description>
      <content:encoded><![CDATA[<p>The previous blogs described how to create an OU, a user account, and a group, and set the description attribute on each of these objects. The next common task is to read an attribute of each object.  <p>Reading an Active Directory object’s attributes involves two simple steps:  <ol> <li>Connect to the Active Directory object you want to read.  <li>Read one or more of the object’s attributes.</li></ol> <p>The goal of the three scripts in this blog will be to read the description attribute of the HR OU, the MyerKen user account, and the Atl-Users group and display their values on the screen.  <p><b>Reading an Attribute of an OU</b> <p>The&nbsp; following script reads and displays the description attribute of the OU named HR in the na.fabrikam.com domain. To carry out this task, the script performs the following steps:  <ol> <li>Connect to the HR OU object in the na.fabrikam.com domain.  <li>Read the object’s description attribute.</li></ol> <p><b>Reading the description Attribute of an OU</b> <p>$objOU = [ADSI]"LDAP://localhost:389/OU=HR,dc=NA,dc=fabrikam,dc=com" <p>$objOU.Get("description") <p>When this script runs in the na.fabrikam.com domain, it echoes the description of the HR OU to the command window, as shown: <p>Human Resources <p><b>Reading an Attribute of a User Account</b> <p>The following script&nbsp;reads and displays the description attribute of the user account named MyerKen, located in the HR OU of the na.fabrikam.com domain.  <ol> <li>Connect to the MyerKen user account object in the HR OU of the na.fabrikam.com domain.  <li>Read the object’s description attribute.</li></ol> <p><b>Reading the description Attribute of a User Account</b> <p>$objUser = [ADSI]"LDAP://localhost:389/CN=MyerKen,OU=HR,dc=NA,dc=fabrikam,dc=com" <p>$objUser.Get("description") <p>When this script runs in the na.fabrikam.com domain, it echoes the description of the user account to the command window, as shown: <p>HR employee <p><b>Reading an Attribute of a Group</b> <p>The following script reads and displays the description attribute of a global group named Atl-Users, located in the HR OU of the na.fabrikam.com domain.  <ol> <li>Connect to the Atl-Users group in the HR OU of the na.fabrikam.com domain.  <li>Read the object’s description attribute.</li></ol> <p><b>Reading the description Attribute of a Group</b> <p>$objGroup =[ADSI]"LDAP://localhost:389/CN=Atl-users,OU=HR,dc=NA,dc=fabrikam,dc=com" <p>$objGroup.Get("description") <p>When this script runs in the na.fabrikam.com domain, it echoes the description of the group to the command window, as shown: <p>Atlanta users <p>Important observations about the scripts in this blog  <ul> <li>They perform the same basic steps: They connect to an Active Directory object and read an attribute of the object.  <li>They use the same method (Get) without regard to the class of object being read.</li></ul> <p>As demonstrated in this blog, the process for reading attributes is uniform from one object to the next. In fact, within a particular task, the steps you follow from one object to the next are consistent. This consistency empowers you to write scripts that can read thousands of attributes from the many objects stored in Active Directory.</p>]]></content:encoded>
    </item>
    <item>
      <title>New community project created for Windows PowerShell Extensions</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/new-community-project-created-for-windows-powershell-extensions</link>
      <pubDate>Mon, 07 Aug 2006 15:52:00 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/08/07/new-community-project-created-for-windows-powershell-extensions/</guid>
      <description><![CDATA[We have worked with CodePlex team to create a new Community Project for Windows...]]></description>
      <content:encoded><![CDATA[<p>We have worked with CodePlex team to create a new Community Project for Windows PowerShell.&nbsp;&nbsp; Keith Hill, MVP for Windows PowerShell, will be the project coordinator.&nbsp; Microsoft employees won't be able to participate in the community projects directly due to legal issues. However, I sincerely hope that community participates in this project and contribute.</p> <p>&nbsp;</p> <p>You can access the project at</p> <p><a href="https://www.codeplex.com/Wiki/View.aspx?ProjectName=PowerShellCX">https://www.codeplex.com/Wiki/View.aspx?ProjectName=PowerShellCX</a></p> <p>&nbsp;</p> <p>Existing&nbsp; Windows PowerShell GotDotNet project at <font color="#000080" size="2"></p> <dir> <dir></font><font size="2"> <p></font><a href="https://www.gotdotnet.com/workspaces/workspace.aspx?id=bd8982c2-9e47-4793-b7c8-35a4c9105330"><u><font color="#0000ff" size="2">https://www.gotdotnet.com/workspaces/workspace.aspx?id=bd8982c2-9e47-4793-b7c8-35a4c9105330</u></font></a></p></dir></dir><?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:personname w:st="on"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'"><font color="#000080" size="2"> <dir> <dir></font></dir></dir></span></st1:personname> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><st1:personname w:st="on"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'"><font color="#000000">will be migrated over to this project.</font></span></st1:personname></p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><st1:personname w:st="on"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'"><font color="#000000"></font></span></st1:personname>&nbsp;</p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><st1:personname w:st="on"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'"><font color="#000000"></font></span></st1:personname>&nbsp;</p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><st1:personname w:st="on"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'">Arul Kumaravel</span></st1:personname><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'">Development Manager </span><span style="font-size: 12pt; color: blue; font-family: 'Times New Roman'"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'">Windows PowerShell<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="font-size: 12pt; color: navy; font-family: 'Times New Roman'">Microsoft Corporation<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="font-size: 12pt; color: blue; font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Technorati Profile</title>
      <link>https://docs.microsoft.com/archive/blogs/arulk/technorati-profile</link>
      <pubDate>Fri, 04 Aug 2006 15:55:00 GMT</pubDate>
      <dc:creator><![CDATA[arulk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/arulk/2006/08/04/technorati-profile/</guid>
      <description><![CDATA[Here is my Technorati profile information for this blog. Technorati Profile
]]></description>
      <content:encoded><![CDATA[Here is my Technorati profile information for this blog. <a href="https://technorati.com/claim/si8igf32sw" rel="me">Technorati Profile</a>
]]></content:encoded>
    </item>
  </channel>
</rss>