Skip to content

Instantly share code, notes, and snippets.

@taddev
Created October 27, 2012 04:37
Show Gist options
  • Save taddev/3962957 to your computer and use it in GitHub Desktop.
Save taddev/3962957 to your computer and use it in GitHub Desktop.
An input test to understand piping in Powershell
param( [switch]$parent, [switch]$child, [switch]$help, [string]$template );
function displayHelp()
{
echo "Input is piped in from the command line.`nThis script will process some stuff";
echo "Parameters:`n";
echo "`t-child`tProcess the child nodes";
echo "`t-parent`tProcess the parent nodes";
echo "`nExample:";
echo "`t1,2,3|.\InputTest.ps1 -child -parent";
}
$count = @($input).Count;
$input.Reset();
if( ( !$parent -and !$child ) -or $help -or ( $count -eq 0 ) -or ( $template.CompareTo("") -eq 0 ) )
{
displayHelp;
break;
}
else
{
if( $parent )
{
echo "You selected Parent";
}
if( $child )
{
echo "You selected Child";
}
echo $template"\_child";
echo "You piped $count values.";
foreach( $numb in $input )
{
echo "Input was: $numb";
}
}
# SIG # Begin signature block
# MIIbaQYJKoZIhvcNAQcCoIIbWjCCG1YCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUzk/jO+iw3dAX9bmQ9rQvQ2+3
# kWugghYbMIIDnzCCAoegAwIBAgIQeaKlhfnRFUIT2bg+9raN7TANBgkqhkiG9w0B
# AQUFADBTMQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xKzAp
# BgNVBAMTIlZlcmlTaWduIFRpbWUgU3RhbXBpbmcgU2VydmljZXMgQ0EwHhcNMTIw
# NTAxMDAwMDAwWhcNMTIxMjMxMjM1OTU5WjBiMQswCQYDVQQGEwJVUzEdMBsGA1UE
# ChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xNDAyBgNVBAMTK1N5bWFudGVjIFRpbWUg
# U3RhbXBpbmcgU2VydmljZXMgU2lnbmVyIC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5PuEZscLeG9XPgPbdFDisOj8TZ4
# oa6fgNPQkM9eQqGCAX8wggF7BgkqhkiG9w0BCQYxggFsMIIBaAIBATBnMFMxCzAJ
# BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjErMCkGA1UEAxMiVmVy
# aVNpZ24gVGltZSBTdGFtcGluZyBTZXJ2aWNlcyBDQQIQeaKlhfnRFUIT2bg+9raN
# 7TAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG
# 9w0BCQUxDxcNMTIxMDI3MDI0NDQ3WjAjBgkqhkiG9w0BCQQxFgQUaF0+UNWlWT+o
# I8hv9M0to5dbGgEwDQYJKoZIhvcNAQEBBQAEgYAbGxImvpw349CQWR1526Org2En
# f6/A0o4GpALQWXDmCWoH0Br7D1/nfStcsgl7zLquWEGQWFQf4HBRh5vI7UqNLRsR
# haBhXjqZeVBYXTIL+QKTRPNiHPR46pcz7u3b/5phIxSzy82wCsIqV0JS2dM7rixw
# Pk1//fQCyg+7LP3CXQ==
# SIG # End signature block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment