|
Re: Need help with .CreationTime I'm a .Net apprentice, so there could very well be a better way. You need to
load Microsoft.VisualBasic.dll from your $profile and create a function
there also, so you can always access it.
This goes in your $profile:
[void][System.Reflection.Assembly]::Load('Microsoft.VisualBasic,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
function Get-WeekOfYear ([dateTime]$date = (get-date))
{
[Microsoft.VisualBasic.DateAndTime]::datePart('ww',($date),1)
}
New-Alias woy Get-WeekOfYear -opt ReadOnly, AllScope -sco Global
.... you can also add a scriptProperty to the [DateTime] type. Put the
following in a ps1xml file, let's say ExtendedTypes.ps1xml
<Types>
<Type>
<Name>System.DateTime</Name>
<Members>
<ScriptProperty>
<Name>WeekOfYear</Name>
<GetScriptBlock>
[Microsoft.VisualBasic.DateAndTime]::datePart('ww',($this),1)
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
....and from your $profile extend the type like this:
Update-TypeData <yourDir>\ExtendedTypes.ps1xml
Then you'll be able to:
woy '7.4.1776'
$weekOfYear = (get-date).weekOfYear
$weekOfYear
--
Kiron |