Reputation:
How i can debug source in powershell line by line ?
i use c# code in powershell like this example :
$Assem = (
“Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” ,
“Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
)
$Source = @”
using Microsoft.SharePoint.Publishing.Administration;
using System;
namespace StefanG.Tools
{
public static class CDRemoteTimeout
{
public static void Get()
{
ContentDeploymentConfiguration cdconfig = ContentDeploymentConfiguration.GetInstance();
Console.WriteLine(“Remote Timeout: “+cdconfig.RemoteTimeout);
}
public static void Set(int seconds)
{
ContentDeploymentConfiguration cdconfig = ContentDeploymentConfiguration.GetInstance();
cdconfig.RemoteTimeout = seconds;
cdconfig.Update();
}
}
}
“@
Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp
[StefanG.Tools.CDRemoteTimeout]::Get()
[StefanG.Tools.CDRemoteTimeout]::Set(600)
and when i start debugging powershell i cant see anything that happen in source . i use powershell_ise . and if someone can please give me good powershell IDE to debug it easy . thanks for any help.
the $source
is an string because of it the debugger just debug add-type at the first line of import source .
Upvotes: 0
Views: 3096
Reputation: 31
Refer http://www.johnchapman.net/technology/coding/powershell-debug-custom-csharp-powershell-cmdlet/
(OR)
You can simply install powershell editor for debugging in powershell window http://dalexandrov.github.io/PowershellEditor/
Upvotes: 3