Char(DesertFish)

A desert-fish want to go heaven.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2010年12月16日

摘要: clsfunction HelloWord{ [System.Windows.Forms.MessageBox]::Show("Hello world!")}[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")$app=[System.Windows.Forms.Application];$myForm=new-object System.Windows.Forms.Form;$myForm.Text="my window";$button1 = new-object System.Windows.Forms.Bu 阅读全文
posted @ 2010-12-16 16:25 沙漠鱼 阅读(347) 评论(0) 推荐(0) 编辑

摘要: filter awk ([scriptblock] $cmd = $args[0], [regex] $delimiter='\s+'){$line = @($delimiter.split($_.Trim()));$countOfBlock = $line.length;$0 = $_;#input from pipelinefor ($i = 1; $i -le $countOfBlock; $i++){Invoke-Expression "`$$i = '$($line[$i - 1])'"}& $cmd} cls$hash = @{}cd "C:\Documents and Setti 阅读全文
posted @ 2010-12-16 16:24 沙漠鱼 阅读(1170) 评论(0) 推荐(0) 编辑

摘要: $ht=@{} $ht.Add("1","55") $ht.Add("11","5555555555555555555555555555") $ht.Add("11111111111111111","5555555555555555555555555555") $ht.Keys | sort |select @{n='ReadCount';e={$_}}, @{n='ElapsedTime';e={$ht[$_].ToString()}} | ft -a $ht.Keys | sort |select @{n='ReadCount';e={$_}}, @{n='ElapsedTime';e={ 阅读全文
posted @ 2010-12-16 16:21 沙漠鱼 阅读(321) 评论(0) 推荐(0) 编辑

摘要: cls$currentDomain = [AppDomain]::CurrentDomain#[AppDomain]::CurrentDomain.GetAssemblies()\#Finding Interesting Classes (Types)$searchtext = "*Environment*"$interstingClass = [AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object { $_.GetExportedTypes() } | Where-Object { $_ -like $searchtext } 阅读全文
posted @ 2010-12-16 16:20 沙漠鱼 阅读(195) 评论(0) 推荐(0) 编辑

摘要: cd "C:\archived\self\task\powershell\test\Other"clsGet-Date$bcpFileCDSIssuerMirror = "GCDR.all_issuers.data.20100921.bcp"$bcpFileCDSIssuerColumnsRemoved = "bcpFileCDSIssuerColumnsRemoved"if ((Test-Path "$bcpFileCDSIssuerColumnsRemoved" -PathType Leaf) -eq $true){ Remove-Item $bcpFileCDSIssuerColumns 阅读全文
posted @ 2010-12-16 16:19 沙漠鱼 阅读(254) 评论(0) 推荐(0) 编辑

摘要: clsfunction ConverterTZI($arg_tzi,$arg_startIndex,$name="NULL"){ $SYSTEMTIME = 1 |select wYear,wMonth,wDayOfWeek,wDay,wHour,wMinute,wSecond,wMilliseconds,Name Add-Member -InputObject $SYSTEMTIME -MemberType ScriptMethod Ini{ $index = $arg_startIndex $this.wYear = [BitConverter]::ToInt16($arg_tzi, $i 阅读全文
posted @ 2010-12-16 16:18 沙漠鱼 阅读(316) 评论(0) 推荐(0) 编辑

摘要: # http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!756.entryclscd "C:\archived\self\task\powershell\test"$file ="C:\archived\self\task\powershell\test\12.3MB.txt"$filefunction ReadCount{ $ht = @{}; for ($i = 1; $i -le 10MB; $i *= 10) { #write-progress "Measuring gc -readCount $i" "% Comp 阅读全文
posted @ 2010-12-16 16:14 沙漠鱼 阅读(314) 评论(0) 推荐(0) 编辑

摘要: function Tail-Content([string[]] $Path,[int] $Last = 10,[string]$Newline=[Environment]::NewLine){ $fs = $null $resolvedPaths = $Path foreach ($rpath in $resolvedPaths) { $numLines = $Last $seekOffset = -1; $PathIntrinsics = $ExecutionContext.SessionState.Path if ($PathIntrinsics.IsProviderQualifi 阅读全文
posted @ 2010-12-16 16:10 沙漠鱼 阅读(1114) 评论(0) 推荐(0) 编辑

摘要: clsfunction aaa{$row3=$table.NewRow();$row3["BugId1"]="23432"$row3["BugId2"]="dfdsfbn"$row3["BugId3"] = 12132$row3["BugId5"] = "gjghjgjgh"$table.Rows.Add($row3);}#创建数据表对象$dataset=New-Object -TypeName System.Data.DataSet;$table = New-Object -TypeName System.Data.DataTable;$column1=$table.Columns.Add( 阅读全文
posted @ 2010-12-16 16:10 沙漠鱼 阅读(745) 评论(0) 推荐(0) 编辑

摘要: cls$EventVwr = Get-EventLog -listforeach ($Log in $EventVwr) {"{0,-28} {1,-20} {2,8}" -f `$Log.log, $Log.OverflowAction, $Log.MaximumKilobytes}"hex format: " + "0x{0:x}" -f 500"Currency Format: " +"{0,-25:C} {1,25:C}" -f 137.30, 88.90"Percentage: " + "{0,-10:p}" -f 0.875, 0.790"Time and Date " +"{0: 阅读全文
posted @ 2010-12-16 16:08 沙漠鱼 阅读(590) 评论(0) 推荐(0) 编辑

摘要: cls$maxQueueConut =5$queneCount =0$queueHead =0$queuetail =0$queue = New-Object int[] ($maxQueueConut)function EnQueue([int] $Value){ if($queneCount -eq $maxQueueConut) { throw "quene is full" } else { $script:queneCount++ $script:queue[$queueHead] = $Value } $script:queueHead = NextIndex $queueHead 阅读全文
posted @ 2010-12-16 16:03 沙漠鱼 阅读(285) 评论(0) 推荐(0) 编辑

摘要: 下面代码基于一个算法题目来实现一个用线性时间得到堆栈最大值的代码。cls$maxStackConut =5$stackTopIndex =-1$stack = New-Object int[] ($maxStackConut)$link2NextMaxItem = New-Object int[] ($maxStackConut)$maxStackItemIndex=-1function Push([int] $Value){ if($stackTopIndex -eq ($maxStackConut-1)) { throw "Stack is full" } else { $script:s 阅读全文
posted @ 2010-12-16 16:02 沙漠鱼 阅读(391) 评论(0) 推荐(0) 编辑