Article archive
Break command
13/10/2012 02:34
#break script, I needed it for validation
#break command
$i=100
if($i -gt 50)
{
write-host "greater than 50"
break
}
else
{
if($i -lt 10)
{
write-host "Less than...
Create profile in Powershell ISE
12/10/2012 21:11
https://brwilkinson.wordpress.com/tag/ise/
Return in function with param
12/10/2012 21:07
function hadajCislo
{ param([int]$cislo)
if($cislo -le 0)
{
return $false
}
else
{return $true}
}
$a=(1, -2, 5, 0, 4, 1, -5)
foreach($item in $a)
{
...
Catch exception
12/10/2012 18:28
#save previous setting
$defaultErrorAction=$ErrorActionPreference
#Force program to catch exception in case of error
$ErrorActionPreference="Stop"
try
{
#use some method with specified exception
$item=$WorkItemStore.GetWorkItem(20156)
}
catch...
Create class in powershell
11/10/2012 22:06
#Define class with properties
$source = @"
public class TaskItem
{
private string title;
public string Title
{
get {return title;}
set {title=value;}
...
Define custom object
11/10/2012 22:01
#Define Custom object in powershell, set properties
$obj = New-Object psobject -Property @{Title="Basic Title"; Description="Basic Description"; Effort=1; Priority=1000}
#you can change properties later
$obj.Title="New Title"
$obj
Skuska kopirovania formatu
10/10/2012 12:07
$workItem=$WorkItemStore.GetWorkItem(1363)
$workItem.WorkItemLinks.Add($link)
$workItem.Save()
$parentId=391
$areaPath=“ComponentFactory\12. External Video"
$iterationPath=“ComponentFactory\Release 1\Sprint 12"
$defaultPriority=1000
#takes component name from...
Fake list and list item, query
10/10/2012 12:03
///
/// VideoWidth is not set, taken from config list, list exists, item exists and has value.
/// Should return item value.
///
[TestMethod()]
public void VideoWidthIsNotSetListItemHasValue()
{
ExternalVideoWP target = new ExternalVideoWP();
target.VideoWidth =...
Create TFS work items by Powershell
09/10/2012 20:46
#Use of client servers
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.TeamFoundation.WorkItemTracking.Client")
[psobject] $tfs =...
Fake private field
09/10/2012 16:41
//in code
private SPListItem configListItem;
//setting value of private field, target is class where is configListItem
var fakeItem = Isolate.Fake.Instance<SPListItem>();
ObjectState.SetField(target, "configListItem", fakeItem);
Button btnRegister =...
Items: 291 - 300 of 384