Last active
July 17, 2017 11:41
-
-
Save cat2151/7adeddee28664472b331fbd1655dc7c5 to your computer and use it in GitHub Desktop.
batファイル内のPowerShell内のC#プログラムを動かす
This file contains 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
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s" %*&goto:eof | |
# http://qiita.com/cd01/items/82829ba0ec0f59e1b04d | |
# http://qiita.com/Kosen-amai/items/d68b9590c9e8e8b06377 | |
Param($argBat) | |
$src = @' | |
using System; | |
public static class HelloClass | |
{ | |
public static string HelloMethod(string arg) | |
{ | |
string msg = "hello " + arg + " world"; | |
Console.WriteLine(msg); | |
return msg; | |
} | |
} | |
'@ | |
Add-Type -TypeDefinition $src -Language CSharp | |
$helloResult = [HelloClass]::HelloMethod($argBat) | |
Write-Output -InputObject $helloResult | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment