The whole point of using ValueFromPipeline (and ValueFromPipelineByPropertyName) is to replace this syntax:
"c:\windows","c:\Program Files" | ForEach-Object {
Get-DirectoryFileSize -Directory $_
}
With this synax:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") | |
Describe "Some-Function" { | |
Mock "Export-ModuleMember" -ParameterFilter { $Function -eq "Some-Function" } -Verifiable | |
#I've moved this down here, is this OK? | |
. "$here\$sut" | |
Context "Other Tests" { |
$VMHost = "yourhost" | |
New-TagCategory -Name "TestCat" | |
New-Tag -Name "TestTag" -Category "TestCat" | |
New-VM -Name "test/tag" -vmhost $VMHost | |
New-TagAssignment -Tag TestTag -Entity "test/tag" | |
Get-TagAssignment -Category "TestCat" | %{$_.entity} | fl |
$ModulePath = Join-Path $env:USERPROFILE "Documents\WindowsPowerShell\Modules" | |
"m1","m2","m3","m4","m5","m6" | %{ mkdir (Join-Path $ModulePath $_ ) -ea 0 } | |
New-ModuleManifest -Path (Join-Path $ModulePath "m1\m1.psd1") -RequiredModules "m5","m2" | |
New-ModuleManifest -Path (Join-Path $ModulePath "m2\m2.psd1") -RequiredModules "m3","m4" | |
New-ModuleManifest -Path (Join-Path $ModulePath "m3\m3.psd1") -RequiredModules "m4" | |
New-ModuleManifest -Path (Join-Path $ModulePath "m4\m4.psd1") -RequiredModules "m5" | |
New-ModuleManifest -Path (Join-Path $ModulePath "m5\m5.psd1") |
<# | |
.DESCRIPTION | |
Outputs the SSL protocols that the client is able to successfully use to connect to a server. | |
.NOTES | |
Copyright 2014 Chris Duck | |
http://blog.whatsupduck.net | |
Licensed under the Apache License, Version 2.0 (the "License"); |
$ModuleName = "YourModule" | |
$Verbs = Get-Command -Module $ModuleName | Select -Unique -ExpandProperty Verb | Sort | |
Get-Command -Module $ModuleName | Group Noun | %{ | |
$Cmds = $_.Group | |
$Noun = $_.Name | |
$VerbCoverage = [Ordered]@{ | |
Noun = $Noun | |
} |
<# | |
Copyright 2015 Chris Duck | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
$TempPath = [IO.Path]::GetTempPath() | |
$SBin = "C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.5.3.60710\sbin" | |
$NodeNameBase = [IO.Path]::GetFileNameWithoutExtension([IO.Path]::GetRandomFileName()) | |
$NodeName = "$NodeNameBase@$Env:COMPUTERNAME" | |
$RabbitBase = Join-Path $TempPath $NodeNameBase | |
$ErlangHome = "c:\Program Files\erl7.0" | |
$RabbitPort = 5672 | |
$MgmtPort = 15672 |
function car { | |
[CmdletBinding(DefaultParameterSetName='DefaultParameter', HelpUri='http://go.microsoft.com/fwlink/?LinkID=113387', RemotingCapability='None')] | |
param( | |
[Parameter(ValueFromPipeline=$true)] | |
[psobject] | |
${InputObject}, | |
[Parameter(ParameterSetName='SkipLastParameter', Position=0)] | |
[Parameter(ParameterSetName='DefaultParameter', Position=0)] | |
[System.Object[]] |
function New-Node { | |
[OutputType("Whatsupduck.Powershell.GraphViz.Node")] | |
param( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[String]$Name, | |
[Parameter(Mandatory=$false)] |
The whole point of using ValueFromPipeline (and ValueFromPipelineByPropertyName) is to replace this syntax:
"c:\windows","c:\Program Files" | ForEach-Object {
Get-DirectoryFileSize -Directory $_
}
With this synax: