This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AbsolutePath { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[string[]] | |
$Path | |
) | |
process { | |
$Path | ForEach-Object { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-TSSession { | |
& query session | | |
Select-Object -Skip 1 | | |
ForEach-Object { | |
if ($_ -match '^(?<this>.)(?<sessionname>.{18})(?<username>.{22})(?<id>.{6})(?<state>.{8})(?<type>.{8})(?<device>.*)') { | |
New-Object -TypeName PSObject -Property @{ | |
SessionName = $Matches.sessionname.TrimEnd() | |
UserName = $Matches.username.TrimEnd() | |
SessionId = [int]::Parse($Matches.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ReportServerUri = 'http://myreportserver/ReportServer/ReportService2005.asmx' | |
$InheritParent = $true | |
$ItemPath = '/SomeReportFolder' | |
$GroupUserName = 'MYDOMAIN\SomeUser' | |
$RoleName = 'SomeReportServerRoleToGrant' | |
$Proxy = New-WebServiceProxy -Uri $ReportServerUri -Namespace SSRS.ReportingService2005 | |
$Policies = $Proxy.GetPolicies($ItemPath, [ref]$InheritParent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# effectively this is VB's Option Strict On but for PowerShell | |
$ErrorActionPreference = 'Stop' | |
Set-StrictMode -Version Latest | |
$buildFile = "build\Build.proj" | |
# simulate the variable representing the folder this script is in (a PS Module would get this by default) | |
$PSScriptRoot = ($MyInvocation.MyCommand.Path | Split-Path | Resolve-Path).ProviderPath | |
# never pass relative paths outside your script |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CollectionUrl = 'http://mytfs:8080/tfs/mycollection' | |
'.Client', '.Build.Client' | % { | |
Add-Type -AssemblyName "Microsoft.TeamFoundation$_, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" | |
} | |
$Collection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $CollectionUrl | |
$BuildServer = $Collection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) | |
$LiveBuildDetail = $BuildServer.GetBuild($TfsDeployerBuildDetail.Uri) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -version 2.0 | |
param ( | |
[ValidateScript({$_ | Test-Path -PathType Container})] | |
[Parameter(Mandatory=$true)] | |
[string] $folder | |
) | |
function killScc(){ | |
gci -path $folder -i *.vssscc,*.vspscc -recurse | Remove-Item -force -verbose | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-CLR4PowerShellCommand { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true)] | |
[ScriptBlock] | |
$ScriptBlock, | |
[Parameter(ValueFromRemainingArguments=$true)] | |
[Alias('Args')] | |
[object[]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Insert this Sequence as one of the last children of the Sequence with DisplayName="Compile and Test" --> | |
<Sequence> | |
<Sequence.Variables> | |
<Variable x:TypeArguments="mtbc:IBuildDetail" Name="LastBuildDetail" /> | |
<Variable x:TypeArguments="x:Int32" Name="LastWarningCount" /> | |
<Variable x:TypeArguments="x:Int32" Name="WarningCount" /> | |
</Sequence.Variables> | |
<Assign x:TypeArguments="mtbc:IBuildDetail" To="[LastBuildDetail]" Value="[BuildDetail.BuildServer.GetBuild(BuildDetail.BuildDefinition.LastBuildUri)]" /> | |
<Assign x:TypeArguments="x:Int32" To="[LastWarningCount]" Value="[Microsoft.TeamFoundation.Build.Client.InformationNodeConverters.GetBuildWarnings(LastBuildDetail).Count]" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-MsiProductVersion { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true)] | |
[ValidateScript({$_ | Test-Path -PathType Leaf})] | |
[string] | |
$Path | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&{ | |
1..7 | |
4..9 | |
} | | |
ForEach-Object -Begin { | |
$Unique = @{} | |
} -Process { | |
if (-not $Unique.ContainsKey($_)) { | |
$Unique.Add($_, $null) | |
$_ |