У меня есть некоторый код c#, смешанный с моим скриптом Powershell, и это сводит с ума пытаться и устранять неполадки, не имея возможности ставить точки останова, где код c# и psjobs.
Я используя Power gui в качестве моей IDE. Если есть лучший способ сделать это, я весь слух. Я потратил огромное количество времени на то, чтобы устранить неполадки с частью c#, как в обычной IDE. c# отлично работает при запуске в c# IDE.
Спасибо
$containerScript = {
$logfile = "c:\temp\powershell_cSharp.txt";
try
{
"try: " + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
$windowFinder = New-Object cSharpNS.CSforPS; # namespace.class
}
catch
{
"catch: " + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
$assemblies = ("System", "System.Data", "System.DirectoryServices", "System.Collections", "System.IO", "System.Windows.Forms", "System.Threading", "System.Runtime.InteropServices", "System.DirectoryServices.AccountManagement", "System.Security.Principal", "System.Drawing");
#Add-Type -TypeDefinition $windowCheck -ReferencedAssemblies $assemblies -Language CSharp;
#Add-Type -TypeDefinition $mailAddr -ReferencedAssemblies $assemblies -Language CSharp;
Add-Type -TypeDefinition $cSharpCode -ReferencedAssemblies $assemblies -Language CSharp; # add the string of c# code
$windowFinder = New-Object cSharpNS.CSforPS; # namespace.class
}
$error.Clear();
"Calling windowFinder.Code() in containerScript_" + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
Write-Host "Calling windowFinder.Code() in containerScript";
$result = $windowFinder.code(); #namespace.class.function
"result: " + $result + "_" + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
"error: " + $error + "_" + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
"Finished windowFinder.Code() in containerScript_" + ([DateTime]::Now.ToString()) | Out-File $logfile -Append;
Write-Host "Finished windowFinder.Code() in containerScript";
}
Start-Job -ScriptBlock $containerScript;
Write-Host "Finished";