protected void ExecuteInternal(ScriptSession scriptSession, string script) { try { if (scriptSession.Debugging) { scriptSession.InitBreakpoints(); } scriptSession.ExecuteScriptPart(script); } finally { if (!string.IsNullOrEmpty(scriptSession.DebugFile)) { File.Delete(scriptSession.DebugFile); scriptSession.DebugFile = string.Empty; scriptSession.ExecuteScriptPart("Get-PSBreakpoint | Remove-PSBreakpoint"); } scriptSession.Debugging = false; scriptSession.Interactive = false; } }