Skip to content

Instantly share code, notes, and snippets.

@pohatu
Created May 7, 2014 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pohatu/80b2b01492b0a22e874e to your computer and use it in GitHub Desktop.
Save pohatu/80b2b01492b0a22e874e to your computer and use it in GitHub Desktop.
# EchoArgs.ps1 is a PowerShell script that compiles EchoArgs.cs code into EchoArgs.exe
# The Add-Type command is used to generate this CS code.
# EchoArgs.exe will be in $env:temp\EchoArgs.exe
# EchoArgs.cs Source Code via Keith Hill
# From PSCX - Power Shell Community Extensions
# URL: http://pscx.codeplex.com/SourceControl/latest#Trunk/Src/EchoArgs/EchoArgs.cs
# LicenseURL: http://pscx.codeplex.com/license
$EchoArgs_CS = @"
//---------------------------------------------------------------------
// Author: Keith Hill
//
// Description: Very simple little console class that you can use to see
// how PowerShell is passing parameters to legacy console
// apps.
//
// Creation Date: March 06, 2006
//---------------------------------------------------------------------
using System;
namespace Pscx.Applications
{
class EchoArgs
{
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
Console.WriteLine("Arg {0} is <{1}>", i, args[i]);
}
Console.WriteLine("\nCommand line:");
Console.WriteLine(Environment.CommandLine);
Console.WriteLine();
}
}
}
"@
$Binary = Join-Path ([io.path]::GetTempPath()) "EchoArgs.exe"
Add-Type -OutputType ConsoleApplication -OutputAssembly $Binary -ReferencedAssemblies "System" -TypeDefinition $EchoArgs_CS
######################################################################################################################################################################
## License Included to Satify 3.B Requirements of Ms-PL
######################################################################################################################################################################
## Microsoft Public License (Ms-PL)
## Microsoft Public License (Ms-PL)
##
## This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
##
## 1. Definitions
##
## The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
##
## A "contribution" is the original software, or any additions or changes to the software.
##
## A "contributor" is any person that distributes its contribution under this license.
##
## "Licensed patents" are a contributor's patent claims that read directly on its contribution.
##
## 2. Grant of Rights
##
## (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
##
## (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
##
## 3. Conditions and Limitations
##
## (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
##
## (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
##
## (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
##
## (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
##
## ## (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment