bin/SnsPsScriptsMonitoring.dll-Help.xml

<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh">
  <!-- Cmdlet: Initialize-SnsModuleState -->
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
    <command:details>
      <command:name>Initialize-SnsModuleState</command:name>
      <command:verb>Initialize</command:verb>
      <command:noun>SnsModuleState</command:noun>
      <maml:description>
        <maml:para>This CmdLet Verifies The Monitoring DataBase Existence And Creates It If Needed.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>This CmdLet Verifies The Monitoring DataBase Existence And Creates It If Needed.</maml:para>
      <maml:para>The CmdLet Is Intended To Be Hidden For The User And To Be Executed Once When The PowerShell Module Is Loaded.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring PowerShell Module Uses A SQLite Serverless DataBase To Store The Required Information About The Scripts Enabled For Monitoring. It Requires The Monitoring DataBase To Be Stored Somewhere Permanently Regardless Of Location Where The PowerShell Module Is Installed. The PowerShell Modules Are Installed In Different Locations Depending Of The Installation Scope. And All Those Locations Are Protected Which Means That If The User Is Running The Module In Not Elevated Mode Will Be Not Able To Write Into The Monitoring DataBase. The Most Appropriate Location In Such Scenarios Is To Make A Subfolder In "ProgramData" Folder Which Is Enumerated By .NET And There Is No Need To Hardcode The Path To The DataBase. The "ProgramData" Folder Itself Is Protected, However The User Created Folders Inside Are Not. From That Perspective The Monitoring DataBase Is Created In:</maml:para>
      <maml:para>"C:\ProgramData\SnsPsScriptsMonitoring\SnsScrMon.db"</maml:para>
      <maml:para>The Monitoring DataBase Used Is A Simple One With A Single Table. During The PowerShell Module Load The Monitoring DataBase Is Verified About:</maml:para>
      <maml:para>-- The Existence Of The DataBase Folder. In Case The Folder Does Not Exists It Is Created. This Requires The First PS Module Load To Be Made In Elevated Mode.</maml:para>
      <maml:para>-- The NTFS Permissions Of The DataBase Folder. "Full Control" Is Granted To Local Users Group.</maml:para>
      <maml:para>-- The Existence Of The DataBase File. In Case The DataBase Is Missing The Module Creates One.</maml:para>
      <maml:para>-- The Tables Located Inside The DataBase. The SnsPsScriptsMonitoring PowerShell Module Uses A Single Table Within Its Own DataBase. In Case Any Other Tables Appear Would Mean That The DataBase Is Modified By The User Using 3rd Party Tools. Such Tables Are Deleted.</maml:para>
      <maml:para>-- The CmdLet Verifies The Existence And The Schema Of The Monitoring Table Within The Monitoring DataBase. In Case The Table Is Missing New One Is Created. In Case The Table Is There But The Table Schema Does Not Match The Module Requirements, Either The Table Is Deleted And New One Is Created Or The Module Exit With Termination Error. The Current Configuration Is To Recreate The Table. The Table Recreation Is Related With Data Lost Which Will Cause All Already Enabled For Monitoring Scripts To Be No Longer Monitored.</maml:para>
      <maml:para>-- The CmdLet Creates A Test Monitoring Entry, Verify Its Creation, Then Delete The Test Entry And Verifies The Deletion. This To Be Confirmed Before The Work IS Started That The User Have The Required Access Rights To The Monitoring DataBase.</maml:para>
      <maml:para>-- The CmdLet Verifies About Outdated Entries Related With Scripts Not Being Monitored For More Than 31 Days. In Case The PowerShell Module Detect Existence Of Entries Outdated For More Than 40 Days The User Input Will Be Ignored And Deletion Of The Outdated Entries Is Enabled. In Case The Deletion Is Enabled The CmdLet Defragment The Monitoring DataBase And Compact The DataBase File In Order To Release The White Space To The Operating System.</maml:para>
      <maml:para>All The Verifications Above Except The Test Entry Creation And Deletion And The Deletion Of The Outdated Entries With Defragmentation And Compacting Are Performed At The Beginning Of Each CmdLet As Well. The Ones That Actively Perform Tests And Defragmentation With Compacting Are Performed Just Once Per Session. In Case The Initial Run Of This CmdLet Is Removed By The User, This CmdLet Is Executed At The Beginning Of The Each Of The Rest CmdLets In The Module. Which Only Slows Down Them When They Are Ran For The First Time.</maml:para>
      <maml:para>The Monitoring Table In The Monitoring DataBase Have Schema Closely Related With The Desired Monitoring Logic. The Table Have The Following DataBase Schema:</maml:para>
      <maml:para>CREATE TABLE IF NOT EXISTS [Monitor]</maml:para>
      <maml:para>(</maml:para>
      <maml:para>[Directory] VARCHAR NOT NULL,</maml:para>
      <maml:para>[Script] VARCHAR NULL,</maml:para>
      <maml:para>[MonitoredFile] VARCHAR PRIMARY KEY UNIQUE NOT NULL,</maml:para>
      <maml:para>[Task] VARCHAR NULL,</maml:para>
      <maml:para>[Pid] INTEGER NULL,</maml:para>
      <maml:para>[Threshold] INTEGER NOT NULL,</maml:para>
      <maml:para>[Enabled] DATETIME NOT NULL DEFAULT(datetime('now','localtime')),</maml:para>
      <maml:para>[Disabled] DATETIME NULL</maml:para>
      <maml:para>);</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Directory] ON [Monitor] ( [Directory] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Script] ON [Monitor] ( [Script] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_MonitoredFile] ON [Monitor] ( [MonitoredFile] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Task] ON [Monitor] ( [Task] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Pid] ON [Monitor] ( [Pid] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Threshold] ON [Monitor] ( [Threshold] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Enabled] ON [Monitor] ( [Enabled] );</maml:para>
      <maml:para>CREATE INDEX IF NOT EXISTS [ind_Monitor_Disabled] ON [Monitor] ( [Disabled] );</maml:para>
      <maml:para>The "MonitoredFile" Column Is Used To Specify A Transcript Or Log File Produced By The Monitored Script Which Is Regularly Updated. The Script That Produce This File Is Considered As Failed Whenever The File Was Not Updated For Period Of Time Specified Within "Threshold" Column Or Its Process Is No Longer Running.</maml:para>
      <maml:para>The "Task" And "Pid" Columns Are Used To Store Information About The Monitored Script. They Are The Input Needed For The Feature That Stop The Failed Scripts Processes And Restarts Their Tasks. This Information Is Not Required As Long As The Restarting Feature Is Not Required. However Without That Information The Restarting Feature Will Not Work.</maml:para>
      <maml:para>The "Directory", "Script" And "Task" Columns Are Used By The Feature Which Automatically Disable From Monitoring Failed Scripts Entries, Whenever New Instance Of The Same Script Is Enabled For Monitoring. An Example Will Be More Appropriate Explanation. If We Have A Script That Produces Different Transcript File On Each Run And It Is Executed With A Scheduled Task. In Case The Script Fail On Some Execution It Will Not Disable Its Own Entry. Lets Assume The CmdLet For Monitoring Detect That And Restart The Script. Then The Script Will Produce New Transcript File Within The Same Folder And It Is Started With The Same Scheduled Task. In That Case The Monitoring CmdLet Have To Take Care And Disable The Entry For The Failed Instance Since The New Instance Is Already Running. For The Enabled And Failed Scripts That This Is Not Applicable The Monitoring Entry Will Remain And The Script Will Continue To Be Reported As Failed Until A User Manually Disable The Entry Using Disable-SnsScriptMonitoring CmdLet.</maml:para>
      <maml:para>The "Enabled" And "Disabled" Columns Actually Determine Whether A Transcript Or Log File From A Script Will Be Monitored About Last Write Time. Each Entry Is Created As Enabled. With Other Words The "Enabled" Column Shall Contain The DateTime When The Entry Was Created And Enabled. The "Disabled" Column Shall Contain The DateTime When The Entry Was Disabled And The Script No Longer Monitored.</maml:para>
    </maml:description>
    <command:syntax>
      <!-- Parameter set: __AllParameterSets -->
      <command:syntaxItem>
        <maml:name>Initialize-SnsModuleState</maml:name>
        <!-- Parameter: DeleteOutdatedEntries -->
        <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
          <maml:name>DeleteOutdatedEntries</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Delete The Outdated Monitoring Entries. As Outdated Monitoring Entries Are Considered Ones Related With Scripts Not Being Monitored For More Than 6 Months.</maml:para>
            <maml:para>Deletion Of The Outdated Entries Automatically Enable The DataBase Defragmentation And Compacting the DataBase File To Release The Whitespace To The Operating System.</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
        <!-- Parameter: DropTableIfVerificationFail -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>DropTableIfVerificationFail</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Drop The Monitoring Table If The Schema Verification Fails.</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <!-- Parameter: DropTableIfVerificationFail -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>DropTableIfVerificationFail</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Drop The Monitoring Table If The Schema Verification Fails.</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
      <!-- Parameter: DeleteOutdatedEntries -->
      <command:parameter required="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
        <maml:name>DeleteOutdatedEntries</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Delete The Outdated Monitoring Entries. As Outdated Monitoring Entries Are Considered Ones Related With Scripts Not Being Monitored For More Than 6 Months.</maml:para>
          <maml:para>Deletion Of The Outdated Entries Automatically Enable The DataBase Defragmentation And Compacting the DataBase File To Release The Whitespace To The Operating System.</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes>
      <command:inputType>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Delete The Outdated Monitoring Entries. As Outdated Monitoring Entries Are Considered Ones Related With Scripts Not Being Monitored For More Than 6 Months.</maml:para>
          <maml:para>Deletion Of The Outdated Entries Automatically Enable The DataBase Defragmentation And Compacting the DataBase File To Release The Whitespace To The Operating System.</maml:para>
        </maml:description>
      </command:inputType>
    </command:inputTypes>
    <command:returnValues>
      <!-- OutputType: Boolean -->
      <command:returnValue>
        <dev:type>
          <maml:name>System.Boolean</maml:name>
          <maml:uri />
        </dev:type>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:title></maml:title>
      <maml:alert>
        <maml:para>AUTHOR: Svetoslav Nedyalkov Savov (svesavov@hotmail.com)</maml:para>
        <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para>
        <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>---------- EXAMPLE 1 ----------</maml:title>
        <dev:code>Initialize-SnsModuleState -DropTableIfVerificationFail -DeleteOutdatedEntries;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText> svesavov / SnsPsScriptsMonitoring - </maml:linkText>
        <maml:uri>https://github.com/svesavov/SnsPsScriptsMonitoring</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> PowerShell Gallery - </maml:linkText>
        <maml:uri>https://www.powershellgallery.com/packages/SnsPsScriptsMonitoring/</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText>
        <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> SQLite V3 - </maml:linkText>
        <maml:uri>https://sqlite.org/index.html</maml:uri>
      </maml:navigationLink>
    </maml:relatedLinks>
  </command:command>
  <!-- Cmdlet: Get-SnsMonitoringEntry -->
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
    <command:details>
      <command:name>Get-SnsMonitoringEntry</command:name>
      <command:verb>Get</command:verb>
      <command:noun>SnsMonitoringEntry</command:noun>
      <maml:description>
        <maml:para>This CmdLet Enumerates Monitoring Entries, Evaluates About Failed Scripts And If Needed Restarts Them.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>This CmdLet Enumerates Monitoring Entries, Evaluates About Failed Scripts And If Needed Restarts Them.</maml:para>
      <maml:para>The Way That This Module Monitors About Failed Scripts, Requires The Monitored Scripts To Write Some Output On A File, Either Transcript Or Log Ones, Called Here Monitored File. Then Get-SnsMonitoringEntry CmdLet Have To Be Executed From Another Script On A Schedule. During The Execution Of The CmdLet It Verifies Whether The Script Process Is running Or The Monitored File Has Not Been Updated For Specified Amount OF Time. In Order The Monitoring To Work Properly The Account Under Who’s Security Context Is Run The Get-SnsMonitoringEntry CmdLet Must Have Enough NTFS Permissions To Verify The Monitored File Existence And LastWriteTime (Modified) File Property.</maml:para>
      <maml:para>In Order The Monitoring To Work Smoothly It Requires Some CmdLets From This Module To Be Run From Within The Monitored Script And Some CmdLets To Be Run From Dedicated Monitoring Script.</maml:para>
      <maml:para>-- The SnsPsScriptsMonitoring Uses A SQLite V3 Serverless DataBase To Keep Track Of The Monitored Scripts And Essential For Their Monitoring Information. When The PowerShell Module Is Loaded For The First Time It Automatically Creates The Monitoring DataBase At The Following Location:</maml:para>
      <maml:para>"C:\ProgramData\SnsPsScriptsMonitoring\SnsScrMon.db"</maml:para>
      <maml:para>Because Creation Of Folders And Files Within That Folder Requires Elevated Access Rights The First Load Of The Module Have To Be In Elevated PowerShell Process. The Consequent Loads Of The Module Doesn’t Require Elevated Mode In Most Of The Cases, Except The Scenario Whenever The Failed Scripts Have To Be Restarted.</maml:para>
      <maml:para>The Information Kept In The Monitoring DataBase Is: "Directory", "Script", "MonitoredFile", "Task", "Pid", "Threshold", "Enabled" And "Disabled".</maml:para>
      <maml:para>"Directory" Is The Folder Where The Monitored File Reside. This Information Is Automatically Generated From The Specified Monitored File.</maml:para>
      <maml:para>"Script" Is The .PS1 File Of The Monitored Script. This Information Is Automatically Generated. In Order The Monitored Script To Be Identified Correctly Enable-SnsScriptMonitoring Have To Be Run From The Monitored Script. In Case The CmdLet Is Included In Additional PowerShell Modules, The CmdLet Will Wrongly Identify The Module File As Monitored Script. This Is Critical Whenever Is Required Automatic Restart OF The Failed Scripts, And For The Automatic Disabling From Monitoring OF Failed Scripts When The Failed Script Is Restarted And Newer Transcript Or Log File Is Enabled For Monitoring.</maml:para>
      <maml:para>"MonitoredFile" Is The Full Absolute UNC Path To The Specified Monitored File. This Must Be Specified Explicitly To Enable-SnsScriptMonitoring CmdLet. There Is No Automatic Generation.</maml:para>
      <maml:para>"Task" Is The Full Path Of The Monitored Script Windows Scheduled Task. This Information Is Not Mandatory However Without It No Automatic Restart Of The Failed Scripts Is Possible. The Module Can Auto Generate The With Limited Success. It Is Preferable That Information To Be Specified To Enable-SnsScriptMonitoring CmdLet.</maml:para>
      <maml:para>"Pid" Is The Process ID Of The PowerShell Process Where Monitored Script Is Executed. This Is Automatically Generated. In Order The Auto Generate To Identify The Correct Process, The Enable-SnsScriptMonitoring Must Be Run From Inside The Monitored Script.</maml:para>
      <maml:para>"Threshold" Is The Time Interval In Minutes About Inactivity Of The Monitored Script Used As A Threshold To Identify Failed Scripts. The Inactivity Is Measured Via Reading The LastWriteTime OF The Script Transcript Or Log File Specified As Monitored File. For The Correct Identifying Please Make Shure That The Monitored Script Update Periodically The Specified Monitored File. The Threshold Shall Be Specified Carefully Depending Of The Intervals That The Monitored File Is Updated. Wrong Threshold Could Cause Working Script To Be Stopped And Restarted In The Middle Of Some Heavy Task.</maml:para>
      <maml:para>"Enabled" Is The Date And Time When The MonitoredFile Is Inserted In The DataBase And Enabled For Monitoring.</maml:para>
      <maml:para>"Disabled" Is The Date And Time When The Monitored Script Finished Successfully And Therefore No Longer Monitored. From That Perspective The CmdLet Disable-SnsScriptMonitoring Have To Be Executed From Within The Monitored Script At The End Of The Script. In Case The Script Fail It Will Not Get To The Point To Disable Itself From Monitoring, And Its Monitoring Entry Will Remain Enabled, Until Get-SnsMonitoringEntry CmdLet Is Executed By The Monitoring Script And The Failure Is Reported Or Actioned. Having That In Mind We Can Imagine That With The Time Will Remain A Lot Of Enabled DataBase Entries Related With Failed Scripts, As They Never Been Disabled. The Get-SnsMonitoringEntry Partially Takes Care About That Via Identifying Newer Monitoring Entries For The Existing Enabled Entries. For Newer Entries Are Considered The Ones That Have The Same Script, The Same Monitored File Directory, And The Same Windows Scheduled Task Path. Considering The Same Monitoring File Is Not An Option Because Whenever The Same File Is Enabled Again Its Previous Entry Is Overwritten Because "MonitoredFile" Column Is Primary Key In The DataBase Table. In Order The Automatic Detection For Newer Monitoring Entries To Work As Expected, The Evaluated Entries Must Have Values In All Of The Mentioned Above 3 Columns. In Case Some Entries Have No Values Them, They Will Be Not Evaluated, And Their Entries Will Remain Enabled In The Monitoring DataBase. To Disable Them The User Can Run Disable-SnsScriptMonitoring Manually To Disable Specific Entry.</maml:para>
      <maml:para>In Addition During The Module Load The Outdated Monitoring Entries Are Deleted And The Monitoring Database Is Defragmented And Shrank To Release Its White Space To The Operating System. For Outdated Entries Are Considered The Ones Which Are Disabled More Than 31 Days Ago. Enabled Entries Are Never Threated As Outdated Regardless Of Their Age.</maml:para>
      <maml:para>-- The Script Which Have To Be Enabled For Monitoring Have To Run Enable-SnsScriptMonitoring CmdLet From Itself At The Beginning. The CmdLet Requires To Be Provided A Transcript Or Log File Which The Script Update Regularly.</maml:para>
      <maml:para>To Ensure That The Monitoring Will Be Able To Restart The Monitored Script The Monitoring Entry Have To Have Scheduled Task And Process Id Of The Monitored Script. The Process Id Is Taken Automatically Via Enumeration Of The Own Process Id. The Windows Scheduled Task Can Be Automatically Enumerated With Limited Success Via Search Among The Windows Schedule Tasks About Task That Have The Monitored Script .PS1 File In "Add arguments (optional):" In The Scheduled Task Action, The Same "Start in (optional):" In The Scheduled Task Action As The Monitored File Directory, Or The Monitored File Directory Have To Be Nested In The Scheduled Task Action "Start in (optional):" Folder. In Case The Enumerated Scheduled Tasks Are Only One Then It Is Considered As Script Scheduled Task. However This To Work The Monitoring Entry Shall Have The Script .PS1 File Which Might Happen Only If Enable-SnsScriptMonitoring Is Executed From The Monitored Script Itself.</maml:para>
      <maml:para>With Other Words If The Monitored Script Is Located In One Folder And The Monitored File Is Located In A Folder Not Nested In The Script Folder There Is No Chance The Windows Scheduled Task To Be Identified Correctly. Also When There Are Multiple Scheduled Tasks For A Single Script For Example To Prepare Daily Weekly And Monthly Reports. This Will Means That 3 Scheduled Tasks Will Be Enumerated and The CmdLet Will Not assign Neither Of Them Because It Is Not Certain Which One Of Them Have to Be Restarted For This Monitoring Entry. Therefore It Is Always Preferable The Windows Scheduled Task To Be Specified Via CmdLet Parameter. In That Case The CmdLet Will Not Enumerate The Windows Scheduled Tasks, And Will Complete A Little Bit Faster.</maml:para>
      <maml:para>To Ensure That The Proper PowerShell Process Is Stopped Whenever The Script Fail, The Information About The Process ID Is Kept In The Monitoring Entry. In Case The Process IS Still Running And Inactive Depending Of The Monitoring Preferences Get-SnsMonitoringEntry Might Try To Stop The Process And Restart The Failed Script Via Running Of Its Scheduled Task. However The Information About The Process ID IS Dynamically Generated, And In Order To Be Correct The Enable-SnsScriptMonitoring Must Be Executed From The Monitored Script. If It Is Run From Another PowerShell Process, The ID OF That Another PowerShell Process Will Be Inserted In The Monitoring DataBase And In Case Of Failure That Another Process Will Be Stopped.</maml:para>
      <maml:para>The Monitored Script Is Not Specified At All. The CmdLet Enumerates From The MyInvocationInfo Object Who Called The CmdLet. To Ensure That The Monitoring Features Works As Expected It IS Very Important The CmdLet To Ba Called From The Script Itself. In Case The Script Uses Its Own Module And The Monitoring Enablement IS Called From There The MyInvocationInfo Object Will Revert The Module Instead OF The Script. Which Might Lead To Improper Behavior Of The Monitoring.</maml:para>
      <maml:para>-- During The Monitored Script Running There Have To Be Another Script Executed On A Schedule Every Few Minutes Depending Of The Desired Outcome And Needed Threshold. The Monitoring Script Have To Invoke Get-SnsMonitoringEntry CmdLet In Regular Intervals To Get Information About The Status Of The Monitored Scripts. Depending Of The Specified To The CmdLet Parameters It Can:</maml:para>
      <maml:para>Enumerate Specific Monitoring Entry Present In The Monitoring DataBase Regardless Whether It Is Enabled Or Disabled.</maml:para>
      <maml:para>Enumerate All Monitoring Entries Present In The Monitoring DataBase Regardless Whether They Are Enabled Or Disabled. Although This Parameter Set Looks Like Suitable To Prepare A Report When The Monitored Scripts Are Ran, It Actually Is Not Suitable For That Purpose. The Problem Is That The "MonitoredFile" Column Is Primary Key In The Monitoring Table. Which Means That It Can Have Unique Values Only. In The Cases When Specific Script Creates A Transcript Or Log File With The Same Name And Path On Each Execution. There Will Be Only One Monitoring Entry For That Script, Because On Each Script Ran The Previous Monitoring Entry Will Be Overwritten, And The Monitoring DataBase Will Keep Only One Entry For Multiple Script Executions. In The Real Life The Monitored file Will Be Overwritten As Well, So In The DataBase Logic There Is No Big Difference. If You Ensure That Each Monitored Script Will Create Different New Transcript Or Log File To Be Monitored, Then The Data From The Monitoring DataBase Can Be Used For Statistics Reports.</maml:para>
      <maml:para>Enumerate All Enabled Monitoring Entries To The Moment Of The CmdLet Execution.</maml:para>
      <maml:para>Enumerate All Enabled Failed Monitoring Entries To The Moment Of The CmdLet Execution. As Failed Are Considered The Scripts Which Did Not Updated Their Transcript Or Log Files For Longer Than The Specified Threshold Or Their Process Is No Longer Running.</maml:para>
      <maml:para>If "RestartFailed" Switch Parameter Is Specified, To Stop The Processes Of The Failed Scripts If They Are Still Running And Restart Their Scheduled Tasks. "RestartFailed" Is Available Only In "Enabled" And "Failed" Parameter Sets. It Will Work Only If The CmdLet Is Executed In Elevated Mode And All The Needed Information Is Available In The Monitoring Entry Inside The Monitoring DataBase.</maml:para>
      <maml:para>Regardless Of The ParameterSet The CmdLet Will Try To Identify Whether There Are Newer Entries For The Enumerated Enabled Ones. In Case Such Are Identified All Older Entries Will Be Disabled And Only The Newer One Will Remain Enabled. Additionally The CmdLet Will Evaluate Whether All Enabled Monitored Files Exist. In Case Some Do Not They Will Be automatically Disabled From Monitoring. From That Perspective It Is Not A Good Idea To Modify The NTFS Permissions Or To Revoke The Access Of The Security Principal That Is Running The CmdLet During The Monitoring. If The CmdLet Looses The Access And Cannot Verify Their Existence, Will Decide That They Are Deleted And Will Disable The Corresponding Monitoring Entries.</maml:para>
      <maml:para>-- Before The Finish The Monitored Script Have To Run Disable-SnsScriptMonitoring To Set Its Monitoring Entry With Disabled Date. This Is Required To Prevent False Positives Related With Failed Scripts Which Actually Completed Successfully. There Is No Specific Requirement That This CmdLet Have To Be Executed From Within The Monitored Script As Long As The Correct Path Is Provided To The CmdLet.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Read What Is Inside The Monitored Files Or Monitored Scripts. It Does Not Send Any Information Outside Its Own Monitoring DataBase Stored Locally. The Module Have No Any Network Capabilities. All The Actions Are Performed Locally. In Case You Need To Put The Monitored File Or The Script On Network Located Resource, Is Possible But You Have To Do It On Such A Manner To Be Presented To The Monitoring PS Module As Local Resource. For Example Map Network Drive.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Send Any Information Over The Internet. Although It Needs Internet To Verify About Newer Versions. If You Feel This As A Tread Or You Need To Run The Module On A Machine Without Network Connection, You Can Modify The Module .PSM1 File To Not Search For Newer Versions. However You Are Missing Any Future New Features Or Bug Fixes If Any Are Reported Or Discovered. You Still Can Install The Newer Versions Manually.</maml:para>
    </maml:description>
    <command:syntax>
      <!-- Parameter set: InputObject -->
      <command:syntaxItem>
        <maml:name>Get-SnsMonitoringEntry</maml:name>
        <!-- Parameter: Path -->
        <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
          <maml:name>Path</maml:name>
          <maml:description>
            <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
            <maml:para>The Parameter Allows Wildcards Both In PowerShell And SQL Syntax.</maml:para>
          </maml:description>
          <command:parameterValue required="true">string</command:parameterValue>
          <dev:type>
            <maml:name>System.String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue></dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
      <!-- Parameter set: All -->
      <command:syntaxItem>
        <maml:name>Get-SnsMonitoringEntry</maml:name>
        <!-- Parameter: All -->
        <command:parameter required="true" globbing="false" pipelineInput="false" position="named">
          <maml:name>All</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Revert All Monitoring Entries Including The Disabled Ones</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
      <!-- Parameter set: Enabled -->
      <command:syntaxItem>
        <maml:name>Get-SnsMonitoringEntry</maml:name>
        <!-- Parameter: Enabled -->
        <command:parameter required="true" globbing="false" pipelineInput="false" position="named">
          <maml:name>Enabled</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Revert Only The Enabled Entries Without To Verify About Failures</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
        <!-- Parameter: RestartFailed -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>RestartFailed</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Try To Restart The Failed Scripts</maml:para>
            <maml:para>In Order This Feature To Work The Monitoring Entry Shall Contain Information About The Process Id Of The PowerShell Process That Is Running The Monitored Script. This Information Is Provided Automatically By Enable-SnsScriptMonitoring CmdLet. However In Order The Information To Be Correct The CmdLet Have To Be Ran From The Monitored Script.</maml:para>
            <maml:para>In Order The CmdLet To Actually Restart The Script It Will Need Information About The Windows Scheduled Task That Have To Be Restarted. In Order This To Work Properly The Scheduled Task Have To Be Configured To Allow Run On Demand. The Scheduled Task Is Provided When The Monitoring Entry Is Created To Enable-SnsScriptMonitoring CmdLet With A Parameter. If Not Provided The CmdLet Will Try To Identify It Automatically. To Avoid Any False Positives Please Make Sure That The Windows Scheduled Task Path Is Specified.</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
      <!-- Parameter set: Failed -->
      <command:syntaxItem>
        <maml:name>Get-SnsMonitoringEntry</maml:name>
        <!-- Parameter: Failed -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>Failed</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Verify The State Of The Scripts Associated With The Monitoring Entries And Revert Only The Ones Which Are Enabled For Monitoring And Failed</maml:para>
            <maml:para>As Failed Are Considered The Scripts Which Did Not Updated Their Transcript Or Log Files For More Than The Specified Threshold Or Their Process Is No Longer Running</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
        <!-- Parameter: RestartFailed -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>RestartFailed</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Try To Restart The Failed Scripts</maml:para>
            <maml:para>In Order This Feature To Work The Monitoring Entry Shall Contain Information About The Process Id Of The PowerShell Process That Is Running The Monitored Script. This Information Is Provided Automatically By Enable-SnsScriptMonitoring CmdLet. However In Order The Information To Be Correct The CmdLet Have To Be Ran From The Monitored Script.</maml:para>
            <maml:para>In Order The CmdLet To Actually Restart The Script It Will Need Information About The Windows Scheduled Task That Have To Be Restarted. In Order This To Work Properly The Scheduled Task Have To Be Configured To Allow Run On Demand. The Scheduled Task Is Provided When The Monitoring Entry Is Created To Enable-SnsScriptMonitoring CmdLet With A Parameter. If Not Provided The CmdLet Will Try To Identify It Automatically. To Avoid Any False Positives Please Make Sure That The Windows Scheduled Task Path Is Specified.</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <!-- Parameter: Path -->
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>Path</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>The Parameter Allows Wildcards Both In PowerShell And SQL Syntax.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>FilePath</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>The Parameter Allows Wildcards Both In PowerShell And SQL Syntax.</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>TranscriptFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>The Parameter Allows Wildcards Both In PowerShell And SQL Syntax.</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>LogFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>The Parameter Allows Wildcards Both In PowerShell And SQL Syntax.</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <!-- Parameter: All -->
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named">
        <maml:name>All</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Revert All Monitoring Entries Including The Disabled Ones</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
      <!-- Parameter: Enabled -->
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named">
        <maml:name>Enabled</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Revert Only The Enabled Entries Without To Verify About Failures</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
      <!-- Parameter: Failed -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>Failed</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Verify The State Of The Scripts Associated With The Monitoring Entries And Revert Only The Ones Which Are Enabled For Monitoring And Failed</maml:para>
          <maml:para>As Failed Are Considered The Scripts Which Did Not Updated Their Transcript Or Log Files For More Than The Specified Threshold Or Their Process Is No Longer Running</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
      <!-- Parameter: RestartFailed -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>RestartFailed</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Try To Restart The Failed Scripts</maml:para>
          <maml:para>In Order This Feature To Work The Monitoring Entry Shall Contain Information About The Process Id Of The PowerShell Process That Is Running The Monitored Script. This Information Is Provided Automatically By Enable-SnsScriptMonitoring CmdLet. However In Order The Information To Be Correct The CmdLet Have To Be Ran From The Monitored Script.</maml:para>
          <maml:para>In Order The CmdLet To Actually Restart The Script It Will Need Information About The Windows Scheduled Task That Have To Be Restarted. In Order This To Work Properly The Scheduled Task Have To Be Configured To Allow Run On Demand. The Scheduled Task Is Provided When The Monitoring Entry Is Created To Enable-SnsScriptMonitoring CmdLet With A Parameter. If Not Provided The CmdLet Will Try To Identify It Automatically. To Avoid Any False Positives Please Make Sure That The Windows Scheduled Task Path Is Specified.</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes />
    <command:returnValues>
      <!-- OutputType: MonitoringEntry -->
      <command:returnValue>
        <dev:type>
          <maml:name>SnsPsScriptsMonitoring.MonitoringEntry</maml:name>
          <maml:uri />
        </dev:type>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:title></maml:title>
      <maml:alert>
        <maml:para>AUTHOR: Svetoslav Nedyalkov Savov (svesavov@hotmail.com)</maml:para>
        <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para>
        <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>---------- EXAMPLE 1 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry[]]$arrEntries = Get-SnsMonitoringEntry -Path "C:\Transcript.txt";</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 2 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry[]]$arrEntries = Get-SnsMonitoringEntry -All;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 3 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry[]]$arrEntries = Get-SnsMonitoringEntry -Enabled;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 4 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry[]]$arrEntries = Get-SnsMonitoringEntry -Failed;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 5 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry[]]$arrEntries = Get-SnsMonitoringEntry -RestartFailed;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText> svesavov / SnsPsScriptsMonitoring - </maml:linkText>
        <maml:uri>https://github.com/svesavov/SnsPsScriptsMonitoring</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> PowerShell Gallery - </maml:linkText>
        <maml:uri>https://www.powershellgallery.com/packages/SnsPsScriptsMonitoring/</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText>
        <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> SQLite V3 - </maml:linkText>
        <maml:uri>https://sqlite.org/index.html</maml:uri>
      </maml:navigationLink>
    </maml:relatedLinks>
  </command:command>
  <!-- Cmdlet: Disable-SnsScriptMonitoring -->
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
    <command:details>
      <command:name>Disable-SnsScriptMonitoring</command:name>
      <command:verb>Disable</command:verb>
      <command:noun>SnsScriptMonitoring</command:noun>
      <maml:description>
        <maml:para>This CmdLet Disables A Monitoring Entry In The Monitoring DataBase.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>This CmdLet Disables A Monitoring Entry In The Monitoring DataBase.</maml:para>
      <maml:para>The Way That This Module Monitors About Failed Scripts, Requires The Monitored Scripts To Write Some Output On A File, Either Transcript Or Log Ones, Called Here Monitored File. Then Get-SnsMonitoringEntry CmdLet Have To Be Executed From Another Script On A Schedule. During The Execution Of The CmdLet It Verifies Whether The Script Process Is running Or The Monitored File Has Not Been Updated For Specified Amount OF Time. In Order The Monitoring To Work Properly The Account Under Who’s Security Context Is Run The Get-SnsMonitoringEntry CmdLet Must Have Enough NTFS Permissions To Verify The Monitored File Existence And LastWriteTime (Modified) File Property.</maml:para>
      <maml:para>In Order The Monitoring To Work Smoothly It Requires Some CmdLets From This Module To Be Run From Within The Monitored Script And Some CmdLets To Be Run From Dedicated Monitoring Script.</maml:para>
      <maml:para>-- The SnsPsScriptsMonitoring Uses A SQLite V3 Serverless DataBase To Keep Track Of The Monitored Scripts And Essential For Their Monitoring Information. When The PowerShell Module Is Loaded For The First Time It Automatically Creates The Monitoring DataBase At The Following Location:</maml:para>
      <maml:para>"C:\ProgramData\SnsPsScriptsMonitoring\SnsScrMon.db"</maml:para>
      <maml:para>Because Creation Of Folders And Files Within That Folder Requires Elevated Access Rights The First Load Of The Module Have To Be In Elevated PowerShell Process. The Consequent Loads Of The Module Doesn’t Require Elevated Mode In Most Of The Cases, Except The Scenario Whenever The Failed Scripts Have To Be Restarted.</maml:para>
      <maml:para>The Information Kept In The Monitoring DataBase Is: "Directory", "Script", "MonitoredFile", "Task", "Pid", "Threshold", "Enabled" And "Disabled".</maml:para>
      <maml:para>"Directory" Is The Folder Where The Monitored File Reside. This Information Is Automatically Generated From The Specified Monitored File.</maml:para>
      <maml:para>"Script" Is The .PS1 File Of The Monitored Script. This Information Is Automatically Generated. In Order The Monitored Script To Be Identified Correctly Enable-SnsScriptMonitoring Have To Be Run From The Monitored Script. In Case The CmdLet Is Included In Additional PowerShell Modules, The CmdLet Will Wrongly Identify The Module File As Monitored Script. This Is Critical Whenever Is Required Automatic Restart OF The Failed Scripts, And For The Automatic Disabling From Monitoring OF Failed Scripts When The Failed Script Is Restarted And Newer Transcript Or Log File Is Enabled For Monitoring.</maml:para>
      <maml:para>"MonitoredFile" Is The Full Absolute UNC Path To The Specified Monitored File. This Must Be Specified Explicitly To Enable-SnsScriptMonitoring CmdLet. There Is No Automatic Generation.</maml:para>
      <maml:para>"Task" Is The Full Path Of The Monitored Script Windows Scheduled Task. This Information Is Not Mandatory However Without It No Automatic Restart Of The Failed Scripts Is Possible. The Module Can Auto Generate The With Limited Success. It Is Preferable That Information To Be Specified To Enable-SnsScriptMonitoring CmdLet.</maml:para>
      <maml:para>"Pid" Is The Process ID Of The PowerShell Process Where Monitored Script Is Executed. This Is Automatically Generated. In Order The Auto Generate To Identify The Correct Process, The Enable-SnsScriptMonitoring Must Be Run From Inside The Monitored Script.</maml:para>
      <maml:para>"Threshold" Is The Time Interval In Minutes About Inactivity Of The Monitored Script Used As A Threshold To Identify Failed Scripts. The Inactivity Is Measured Via Reading The LastWriteTime OF The Script Transcript Or Log File Specified As Monitored File. For The Correct Identifying Please Make Shure That The Monitored Script Update Periodically The Specified Monitored File. The Threshold Shall Be Specified Carefully Depending Of The Intervals That The Monitored File Is Updated. Wrong Threshold Could Cause Working Script To Be Stopped And Restarted In The Middle Of Some Heavy Task.</maml:para>
      <maml:para>"Enabled" Is The Date And Time When The MonitoredFile Is Inserted In The DataBase And Enabled For Monitoring.</maml:para>
      <maml:para>"Disabled" Is The Date And Time When The Monitored Script Finished Successfully And Therefore No Longer Monitored. From That Perspective The CmdLet Disable-SnsScriptMonitoring Have To Be Executed From Within The Monitored Script At The End Of The Script. In Case The Script Fail It Will Not Get To The Point To Disable Itself From Monitoring, And Its Monitoring Entry Will Remain Enabled, Until Get-SnsMonitoringEntry CmdLet Is Executed By The Monitoring Script And The Failure Is Reported Or Actioned. Having That In Mind We Can Imagine That With The Time Will Remain A Lot Of Enabled DataBase Entries Related With Failed Scripts, As They Never Been Disabled. The Get-SnsMonitoringEntry Partially Takes Care About That Via Identifying Newer Monitoring Entries For The Existing Enabled Entries. For Newer Entries Are Considered The Ones That Have The Same Script, The Same Monitored File Directory, And The Same Windows Scheduled Task Path. Considering The Same Monitoring File Is Not An Option Because Whenever The Same File Is Enabled Again Its Previous Entry Is Overwritten Because "MonitoredFile" Column Is Primary Key In The DataBase Table. In Order The Automatic Detection For Newer Monitoring Entries To Work As Expected, The Evaluated Entries Must Have Values In All Of The Mentioned Above 3 Columns. In Case Some Entries Have No Values Them, They Will Be Not Evaluated, And Their Entries Will Remain Enabled In The Monitoring DataBase. To Disable Them The User Can Run Disable-SnsScriptMonitoring Manually To Disable Specific Entry.</maml:para>
      <maml:para>In Addition During The Module Load The Outdated Monitoring Entries Are Deleted And The Monitoring Database Is Defragmented And Shrank To Release Its White Space To The Operating System. For Outdated Entries Are Considered The Ones Which Are Disabled More Than 31 Days Ago. Enabled Entries Are Never Threated As Outdated Regardless Of Their Age.</maml:para>
      <maml:para>-- The Script Which Have To Be Enabled For Monitoring Have To Run Enable-SnsScriptMonitoring CmdLet From Itself At The Beginning. The CmdLet Requires To Be Provided A Transcript Or Log File Which The Script Update Regularly.</maml:para>
      <maml:para>To Ensure That The Monitoring Will Be Able To Restart The Monitored Script The Monitoring Entry Have To Have Scheduled Task And Process Id Of The Monitored Script. The Process Id Is Taken Automatically Via Enumeration Of The Own Process Id. The Windows Scheduled Task Can Be Automatically Enumerated With Limited Success Via Search Among The Windows Schedule Tasks About Task That Have The Monitored Script .PS1 File In "Add arguments (optional):" In The Scheduled Task Action, The Same "Start in (optional):" In The Scheduled Task Action As The Monitored File Directory, Or The Monitored File Directory Have To Be Nested In The Scheduled Task Action "Start in (optional):" Folder. In Case The Enumerated Scheduled Tasks Are Only One Then It Is Considered As Script Scheduled Task. However This To Work The Monitoring Entry Shall Have The Script .PS1 File Which Might Happen Only If Enable-SnsScriptMonitoring Is Executed From The Monitored Script Itself.</maml:para>
      <maml:para>With Other Words If The Monitored Script Is Located In One Folder And The Monitored File Is Located In A Folder Not Nested In The Script Folder There Is No Chance The Windows Scheduled Task To Be Identified Correctly. Also When There Are Multiple Scheduled Tasks For A Single Script For Example To Prepare Daily Weekly And Monthly Reports. This Will Means That 3 Scheduled Tasks Will Be Enumerated and The CmdLet Will Not assign Neither Of Them Because It Is Not Certain Which One Of Them Have to Be Restarted For This Monitoring Entry. Therefore It Is Always Preferable The Windows Scheduled Task To Be Specified Via CmdLet Parameter. In That Case The CmdLet Will Not Enumerate The Windows Scheduled Tasks, And Will Complete A Little Bit Faster.</maml:para>
      <maml:para>To Ensure That The Proper PowerShell Process Is Stopped Whenever The Script Fail, The Information About The Process ID Is Kept In The Monitoring Entry. In Case The Process IS Still Running And Inactive Depending Of The Monitoring Preferences Get-SnsMonitoringEntry Might Try To Stop The Process And Restart The Failed Script Via Running Of Its Scheduled Task. However The Information About The Process ID IS Dynamically Generated, And In Order To Be Correct The Enable-SnsScriptMonitoring Must Be Executed From The Monitored Script. If It Is Run From Another PowerShell Process, The ID OF That Another PowerShell Process Will Be Inserted In The Monitoring DataBase And In Case Of Failure That Another Process Will Be Stopped.</maml:para>
      <maml:para>The Monitored Script Is Not Specified At All. The CmdLet Enumerates From The MyInvocationInfo Object Who Called The CmdLet. To Ensure That The Monitoring Features Works As Expected It IS Very Important The CmdLet To Ba Called From The Script Itself. In Case The Script Uses Its Own Module And The Monitoring Enablement IS Called From There The MyInvocationInfo Object Will Revert The Module Instead OF The Script. Which Might Lead To Improper Behavior Of The Monitoring.</maml:para>
      <maml:para>-- During The Monitored Script Running There Have To Be Another Script Executed On A Schedule Every Few Minutes Depending Of The Desired Outcome And Needed Threshold. The Monitoring Script Have To Invoke Get-SnsMonitoringEntry CmdLet In Regular Intervals To Get Information About The Status Of The Monitored Scripts. Depending Of The Specified To The CmdLet Parameters It Can:</maml:para>
      <maml:para>Enumerate Specific Monitoring Entry Present In The Monitoring DataBase Regardless Whether It Is Enabled Or Disabled.</maml:para>
      <maml:para>Enumerate All Monitoring Entries Present In The Monitoring DataBase Regardless Whether They Are Enabled Or Disabled. Although This Parameter Set Looks Like Suitable To Prepare A Report When The Monitored Scripts Are Ran, It Actually Is Not Suitable For That Purpose. The Problem Is That The "MonitoredFile" Column Is Primary Key In The Monitoring Table. Which Means That It Can Have Unique Values Only. In The Cases When Specific Script Creates A Transcript Or Log File With The Same Name And Path On Each Execution. There Will Be Only One Monitoring Entry For That Script, Because On Each Script Ran The Previous Monitoring Entry Will Be Overwritten, And The Monitoring DataBase Will Keep Only One Entry For Multiple Script Executions. In The Real Life The Monitored file Will Be Overwritten As Well, So In The DataBase Logic There Is No Big Difference. If You Ensure That Each Monitored Script Will Create Different New Transcript Or Log File To Be Monitored, Then The Data From The Monitoring DataBase Can Be Used For Statistics Reports.</maml:para>
      <maml:para>Enumerate All Enabled Monitoring Entries To The Moment Of The CmdLet Execution.</maml:para>
      <maml:para>Enumerate All Enabled Failed Monitoring Entries To The Moment Of The CmdLet Execution. As Failed Are Considered The Scripts Which Did Not Updated Their Transcript Or Log Files For Longer Than The Specified Threshold Or Their Process Is No Longer Running.</maml:para>
      <maml:para>If "RestartFailed" Switch Parameter Is Specified, To Stop The Processes Of The Failed Scripts If They Are Still Running And Restart Their Scheduled Tasks. "RestartFailed" Is Available Only In "Enabled" And "Failed" Parameter Sets. It Will Work Only If The CmdLet Is Executed In Elevated Mode And All The Needed Information Is Available In The Monitoring Entry Inside The Monitoring DataBase.</maml:para>
      <maml:para>Regardless Of The ParameterSet The CmdLet Will Try To Identify Whether There Are Newer Entries For The Enumerated Enabled Ones. In Case Such Are Identified All Older Entries Will Be Disabled And Only The Newer One Will Remain Enabled. Additionally The CmdLet Will Evaluate Whether All Enabled Monitored Files Exist. In Case Some Do Not They Will Be automatically Disabled From Monitoring. From That Perspective It Is Not A Good Idea To Modify The NTFS Permissions Or To Revoke The Access Of The Security Principal That Is Running The CmdLet During The Monitoring. If The CmdLet Looses The Access And Cannot Verify Their Existence, Will Decide That They Are Deleted And Will Disable The Corresponding Monitoring Entries.</maml:para>
      <maml:para>-- Before The Finish The Monitored Script Have To Run Disable-SnsScriptMonitoring To Set Its Monitoring Entry With Disabled Date. This Is Required To Prevent False Positives Related With Failed Scripts Which Actually Completed Successfully. There Is No Specific Requirement That This CmdLet Have To Be Executed From Within The Monitored Script As Long As The Correct Path Is Provided To The CmdLet.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Read What Is Inside The Monitored Files Or Monitored Scripts. It Does Not Send Any Information Outside Its Own Monitoring DataBase Stored Locally. The Module Have No Any Network Capabilities. All The Actions Are Performed Locally. In Case You Need To Put The Monitored File Or The Script On Network Located Resource, Is Possible But You Have To Do It On Such A Manner To Be Presented To The Monitoring PS Module As Local Resource. For Example Map Network Drive.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Send Any Information Over The Internet. Although It Needs Internet To Verify About Newer Versions. If You Feel This As A Tread Or You Need To Run The Module On A Machine Without Network Connection, You Can Modify The Module .PSM1 File To Not Search For Newer Versions. However You Are Missing Any Future New Features Or Bug Fixes If Any Are Reported Or Discovered. You Still Can Install The Newer Versions Manually.</maml:para>
    </maml:description>
    <command:syntax>
      <!-- Parameter set: __AllParameterSets -->
      <command:syntaxItem>
        <maml:name>Disable-SnsScriptMonitoring</maml:name>
        <!-- Parameter: Path -->
        <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
          <maml:name>Path</maml:name>
          <maml:description>
            <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          </maml:description>
          <command:parameterValue required="true">string</command:parameterValue>
          <dev:type>
            <maml:name>System.String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue></dev:defaultValue>
        </command:parameter>
        <!-- Parameter: PassThru -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>PassThru</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Revert A PSCustomObject With The Monitoring Entry</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <!-- Parameter: Path -->
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>Path</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>FilePath</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>TranscriptFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>LogFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <!-- Parameter: PassThru -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>PassThru</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Revert A PSCustomObject With The Monitoring Entry</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes />
    <command:returnValues>
      <!-- OutputType: MonitoringEntry -->
      <command:returnValue>
        <dev:type>
          <maml:name>SnsPsScriptsMonitoring.MonitoringEntry</maml:name>
          <maml:uri />
        </dev:type>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:title></maml:title>
      <maml:alert>
        <maml:para>AUTHOR: Svetoslav Nedyalkov Savov (svesavov@hotmail.com)</maml:para>
        <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para>
        <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>---------- EXAMPLE 1 ----------</maml:title>
        <dev:code>Disable-SnsScriptMonitoring -Path "C:\Transcript.txt";</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 2 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry]$objEntry = Disable-SnsScriptMonitoring -Path "C:\Transcript.txt" `
-PassThru;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText> svesavov / SnsPsScriptsMonitoring - </maml:linkText>
        <maml:uri>https://github.com/svesavov/SnsPsScriptsMonitoring</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> PowerShell Gallery - </maml:linkText>
        <maml:uri>https://www.powershellgallery.com/packages/SnsPsScriptsMonitoring/</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText>
        <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> SQLite V3 - </maml:linkText>
        <maml:uri>https://sqlite.org/index.html</maml:uri>
      </maml:navigationLink>
    </maml:relatedLinks>
  </command:command>
  <!-- Cmdlet: Enable-SnsScriptMonitoring -->
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
    <command:details>
      <command:name>Enable-SnsScriptMonitoring</command:name>
      <command:verb>Enable</command:verb>
      <command:noun>SnsScriptMonitoring</command:noun>
      <maml:description>
        <maml:para>This CmdLet Creates A Monitoring Entry In The Monitoring DataBase.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>This CmdLet Creates A Monitoring Entry In The Monitoring DataBase.</maml:para>
      <maml:para>The Way That This Module Monitors About Failed Scripts, Requires The Monitored Scripts To Write Some Output On A File, Either Transcript Or Log Ones, Called Here Monitored File. Then Get-SnsMonitoringEntry CmdLet Have To Be Executed From Another Script On A Schedule. During The Execution Of The CmdLet It Verifies Whether The Script Process Is running Or The Monitored File Has Not Been Updated For Specified Amount OF Time. In Order The Monitoring To Work Properly The Account Under Who’s Security Context Is Run The Get-SnsMonitoringEntry CmdLet Must Have Enough NTFS Permissions To Verify The Monitored File Existence And LastWriteTime (Modified) File Property.</maml:para>
      <maml:para>In Order The Monitoring To Work Smoothly It Requires Some CmdLets From This Module To Be Run From Within The Monitored Script And Some CmdLets To Be Run From Dedicated Monitoring Script.</maml:para>
      <maml:para>-- The SnsPsScriptsMonitoring Uses A SQLite V3 Serverless DataBase To Keep Track Of The Monitored Scripts And Essential For Their Monitoring Information. When The PowerShell Module Is Loaded For The First Time It Automatically Creates The Monitoring DataBase At The Following Location:</maml:para>
      <maml:para>"C:\ProgramData\SnsPsScriptsMonitoring\SnsScrMon.db"</maml:para>
      <maml:para>Because Creation Of Folders And Files Within That Folder Requires Elevated Access Rights The First Load Of The Module Have To Be In Elevated PowerShell Process. The Consequent Loads Of The Module Doesn’t Require Elevated Mode In Most Of The Cases, Except The Scenario Whenever The Failed Scripts Have To Be Restarted.</maml:para>
      <maml:para>The Information Kept In The Monitoring DataBase Is: "Directory", "Script", "MonitoredFile", "Task", "Pid", "Threshold", "Enabled" And "Disabled".</maml:para>
      <maml:para>"Directory" Is The Folder Where The Monitored File Reside. This Information Is Automatically Generated From The Specified Monitored File.</maml:para>
      <maml:para>"Script" Is The .PS1 File Of The Monitored Script. This Information Is Automatically Generated. In Order The Monitored Script To Be Identified Correctly Enable-SnsScriptMonitoring Have To Be Run From The Monitored Script. In Case The CmdLet Is Included In Additional PowerShell Modules, The CmdLet Will Wrongly Identify The Module File As Monitored Script. This Is Critical Whenever Is Required Automatic Restart OF The Failed Scripts, And For The Automatic Disabling From Monitoring OF Failed Scripts When The Failed Script Is Restarted And Newer Transcript Or Log File Is Enabled For Monitoring.</maml:para>
      <maml:para>"MonitoredFile" Is The Full Absolute UNC Path To The Specified Monitored File. This Must Be Specified Explicitly To Enable-SnsScriptMonitoring CmdLet. There Is No Automatic Generation.</maml:para>
      <maml:para>"Task" Is The Full Path Of The Monitored Script Windows Scheduled Task. This Information Is Not Mandatory However Without It No Automatic Restart Of The Failed Scripts Is Possible. The Module Can Auto Generate The With Limited Success. It Is Preferable That Information To Be Specified To Enable-SnsScriptMonitoring CmdLet.</maml:para>
      <maml:para>"Pid" Is The Process ID Of The PowerShell Process Where Monitored Script Is Executed. This Is Automatically Generated. In Order The Auto Generate To Identify The Correct Process, The Enable-SnsScriptMonitoring Must Be Run From Inside The Monitored Script.</maml:para>
      <maml:para>"Threshold" Is The Time Interval In Minutes About Inactivity Of The Monitored Script Used As A Threshold To Identify Failed Scripts. The Inactivity Is Measured Via Reading The LastWriteTime OF The Script Transcript Or Log File Specified As Monitored File. For The Correct Identifying Please Make Shure That The Monitored Script Update Periodically The Specified Monitored File. The Threshold Shall Be Specified Carefully Depending Of The Intervals That The Monitored File Is Updated. Wrong Threshold Could Cause Working Script To Be Stopped And Restarted In The Middle Of Some Heavy Task.</maml:para>
      <maml:para>"Enabled" Is The Date And Time When The MonitoredFile Is Inserted In The DataBase And Enabled For Monitoring.</maml:para>
      <maml:para>"Disabled" Is The Date And Time When The Monitored Script Finished Successfully And Therefore No Longer Monitored. From That Perspective The CmdLet Disable-SnsScriptMonitoring Have To Be Executed From Within The Monitored Script At The End Of The Script. In Case The Script Fail It Will Not Get To The Point To Disable Itself From Monitoring, And Its Monitoring Entry Will Remain Enabled, Until Get-SnsMonitoringEntry CmdLet Is Executed By The Monitoring Script And The Failure Is Reported Or Actioned. Having That In Mind We Can Imagine That With The Time Will Remain A Lot Of Enabled DataBase Entries Related With Failed Scripts, As They Never Been Disabled. The Get-SnsMonitoringEntry Partially Takes Care About That Via Identifying Newer Monitoring Entries For The Existing Enabled Entries. For Newer Entries Are Considered The Ones That Have The Same Script, The Same Monitored File Directory, And The Same Windows Scheduled Task Path. Considering The Same Monitoring File Is Not An Option Because Whenever The Same File Is Enabled Again Its Previous Entry Is Overwritten Because "MonitoredFile" Column Is Primary Key In The DataBase Table. In Order The Automatic Detection For Newer Monitoring Entries To Work As Expected, The Evaluated Entries Must Have Values In All Of The Mentioned Above 3 Columns. In Case Some Entries Have No Values Them, They Will Be Not Evaluated, And Their Entries Will Remain Enabled In The Monitoring DataBase. To Disable Them The User Can Run Disable-SnsScriptMonitoring Manually To Disable Specific Entry.</maml:para>
      <maml:para>In Addition During The Module Load The Outdated Monitoring Entries Are Deleted And The Monitoring Database Is Defragmented And Shrank To Release Its White Space To The Operating System. For Outdated Entries Are Considered The Ones Which Are Disabled More Than 31 Days Ago. Enabled Entries Are Never Threated As Outdated Regardless Of Their Age.</maml:para>
      <maml:para>-- The Script Which Have To Be Enabled For Monitoring Have To Run Enable-SnsScriptMonitoring CmdLet From Itself At The Beginning. The CmdLet Requires To Be Provided A Transcript Or Log File Which The Script Update Regularly.</maml:para>
      <maml:para>To Ensure That The Monitoring Will Be Able To Restart The Monitored Script The Monitoring Entry Have To Have Scheduled Task And Process Id Of The Monitored Script. The Process Id Is Taken Automatically Via Enumeration Of The Own Process Id. The Windows Scheduled Task Can Be Automatically Enumerated With Limited Success Via Search Among The Windows Schedule Tasks About Task That Have The Monitored Script .PS1 File In "Add arguments (optional):" In The Scheduled Task Action, The Same "Start in (optional):" In The Scheduled Task Action As The Monitored File Directory, Or The Monitored File Directory Have To Be Nested In The Scheduled Task Action "Start in (optional):" Folder. In Case The Enumerated Scheduled Tasks Are Only One Then It Is Considered As Script Scheduled Task. However This To Work The Monitoring Entry Shall Have The Script .PS1 File Which Might Happen Only If Enable-SnsScriptMonitoring Is Executed From The Monitored Script Itself.</maml:para>
      <maml:para>With Other Words If The Monitored Script Is Located In One Folder And The Monitored File Is Located In A Folder Not Nested In The Script Folder There Is No Chance The Windows Scheduled Task To Be Identified Correctly. Also When There Are Multiple Scheduled Tasks For A Single Script For Example To Prepare Daily Weekly And Monthly Reports. This Will Means That 3 Scheduled Tasks Will Be Enumerated and The CmdLet Will Not assign Neither Of Them Because It Is Not Certain Which One Of Them Have to Be Restarted For This Monitoring Entry. Therefore It Is Always Preferable The Windows Scheduled Task To Be Specified Via CmdLet Parameter. In That Case The CmdLet Will Not Enumerate The Windows Scheduled Tasks, And Will Complete A Little Bit Faster.</maml:para>
      <maml:para>To Ensure That The Proper PowerShell Process Is Stopped Whenever The Script Fail, The Information About The Process ID Is Kept In The Monitoring Entry. In Case The Process IS Still Running And Inactive Depending Of The Monitoring Preferences Get-SnsMonitoringEntry Might Try To Stop The Process And Restart The Failed Script Via Running Of Its Scheduled Task. However The Information About The Process ID IS Dynamically Generated, And In Order To Be Correct The Enable-SnsScriptMonitoring Must Be Executed From The Monitored Script. If It Is Run From Another PowerShell Process, The ID OF That Another PowerShell Process Will Be Inserted In The Monitoring DataBase And In Case Of Failure That Another Process Will Be Stopped.</maml:para>
      <maml:para>The Monitored Script Is Not Specified At All. The CmdLet Enumerates From The MyInvocationInfo Object Who Called The CmdLet. To Ensure That The Monitoring Features Works As Expected It IS Very Important The CmdLet To Ba Called From The Script Itself. In Case The Script Uses Its Own Module And The Monitoring Enablement IS Called From There The MyInvocationInfo Object Will Revert The Module Instead OF The Script. Which Might Lead To Improper Behavior Of The Monitoring.</maml:para>
      <maml:para>-- During The Monitored Script Running There Have To Be Another Script Executed On A Schedule Every Few Minutes Depending Of The Desired Outcome And Needed Threshold. The Monitoring Script Have To Invoke Get-SnsMonitoringEntry CmdLet In Regular Intervals To Get Information About The Status Of The Monitored Scripts. Depending Of The Specified To The CmdLet Parameters It Can:</maml:para>
      <maml:para>Enumerate Specific Monitoring Entry Present In The Monitoring DataBase Regardless Whether It Is Enabled Or Disabled.</maml:para>
      <maml:para>Enumerate All Monitoring Entries Present In The Monitoring DataBase Regardless Whether They Are Enabled Or Disabled. Although This Parameter Set Looks Like Suitable To Prepare A Report When The Monitored Scripts Are Ran, It Actually Is Not Suitable For That Purpose. The Problem Is That The "MonitoredFile" Column Is Primary Key In The Monitoring Table. Which Means That It Can Have Unique Values Only. In The Cases When Specific Script Creates A Transcript Or Log File With The Same Name And Path On Each Execution. There Will Be Only One Monitoring Entry For That Script, Because On Each Script Ran The Previous Monitoring Entry Will Be Overwritten, And The Monitoring DataBase Will Keep Only One Entry For Multiple Script Executions. In The Real Life The Monitored file Will Be Overwritten As Well, So In The DataBase Logic There Is No Big Difference. If You Ensure That Each Monitored Script Will Create Different New Transcript Or Log File To Be Monitored, Then The Data From The Monitoring DataBase Can Be Used For Statistics Reports.</maml:para>
      <maml:para>Enumerate All Enabled Monitoring Entries To The Moment Of The CmdLet Execution.</maml:para>
      <maml:para>Enumerate All Enabled Failed Monitoring Entries To The Moment Of The CmdLet Execution. As Failed Are Considered The Scripts Which Did Not Updated Their Transcript Or Log Files For Longer Than The Specified Threshold Or Their Process Is No Longer Running.</maml:para>
      <maml:para>If "RestartFailed" Switch Parameter Is Specified, To Stop The Processes Of The Failed Scripts If They Are Still Running And Restart Their Scheduled Tasks. "RestartFailed" Is Available Only In "Enabled" And "Failed" Parameter Sets. It Will Work Only If The CmdLet Is Executed In Elevated Mode And All The Needed Information Is Available In The Monitoring Entry Inside The Monitoring DataBase.</maml:para>
      <maml:para>Regardless Of The ParameterSet The CmdLet Will Try To Identify Whether There Are Newer Entries For The Enumerated Enabled Ones. In Case Such Are Identified All Older Entries Will Be Disabled And Only The Newer One Will Remain Enabled. Additionally The CmdLet Will Evaluate Whether All Enabled Monitored Files Exist. In Case Some Do Not They Will Be automatically Disabled From Monitoring. From That Perspective It Is Not A Good Idea To Modify The NTFS Permissions Or To Revoke The Access Of The Security Principal That Is Running The CmdLet During The Monitoring. If The CmdLet Looses The Access And Cannot Verify Their Existence, Will Decide That They Are Deleted And Will Disable The Corresponding Monitoring Entries.</maml:para>
      <maml:para>-- Before The Finish The Monitored Script Have To Run Disable-SnsScriptMonitoring To Set Its Monitoring Entry With Disabled Date. This Is Required To Prevent False Positives Related With Failed Scripts Which Actually Completed Successfully. There Is No Specific Requirement That This CmdLet Have To Be Executed From Within The Monitored Script As Long As The Correct Path Is Provided To The CmdLet.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Read What Is Inside The Monitored Files Or Monitored Scripts. It Does Not Send Any Information Outside Its Own Monitoring DataBase Stored Locally. The Module Have No Any Network Capabilities. All The Actions Are Performed Locally. In Case You Need To Put The Monitored File Or The Script On Network Located Resource, Is Possible But You Have To Do It On Such A Manner To Be Presented To The Monitoring PS Module As Local Resource. For Example Map Network Drive.</maml:para>
      <maml:para>The SnsPsScriptsMonitoring Does Not Send Any Information Over The Internet. Although It Needs Internet To Verify About Newer Versions. If You Feel This As A Tread Or You Need To Run The Module On A Machine Without Network Connection, You Can Modify The Module .PSM1 File To Not Search For Newer Versions. However You Are Missing Any Future New Features Or Bug Fixes If Any Are Reported Or Discovered. You Still Can Install The Newer Versions Manually.</maml:para>
    </maml:description>
    <command:syntax>
      <!-- Parameter set: __AllParameterSets -->
      <command:syntaxItem>
        <maml:name>Enable-SnsScriptMonitoring</maml:name>
        <!-- Parameter: Path -->
        <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
          <maml:name>Path</maml:name>
          <maml:description>
            <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          </maml:description>
          <command:parameterValue required="true">string</command:parameterValue>
          <dev:type>
            <maml:name>System.String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue></dev:defaultValue>
        </command:parameter>
        <!-- Parameter: PassThru -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>PassThru</maml:name>
          <maml:description>
            <maml:para>Specifies To The CmdLet To Revert A PSCustomObject With The Monitoring Entry</maml:para>
          </maml:description>
          <command:parameterValue required="true">SwitchParameter</command:parameterValue>
          <dev:type>
            <maml:name>System.Management.Automation.SwitchParameter</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>False</dev:defaultValue>
        </command:parameter>
        <!-- Parameter: ScheduledTask -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>ScheduledTask</maml:name>
          <maml:description>
            <maml:para>Specifies The Path To The Monitored Script Windows Scheduled Task</maml:para>
            <maml:para>If Omitted The CmdLet Will Try To Auto Generate It</maml:para>
            <maml:para>If Auto Generation Fail And The Monitoring Entry Is Created Without Scheduled Task</maml:para>
            <maml:para>The Monitoring CmdLet Will Not Attempt To Restart The Script In Case The Script Fail</maml:para>
          </maml:description>
          <command:parameterValue required="true">string</command:parameterValue>
          <dev:type>
            <maml:name>System.String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue></dev:defaultValue>
        </command:parameter>
        <!-- Parameter: Threshold -->
        <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
          <maml:name>Threshold</maml:name>
          <maml:description>
            <maml:para>Specifies The Script Inactivity Threshold In Minutes</maml:para>
            <maml:para>Valid Range From 1 To 1440</maml:para>
            <maml:para>The Threshold Have To Be Specified Carefully. It Might Happen That The Monitored Script Makes Some Heavy Tasks Against Remote Location. Like For Example To Get Azure Logs With Thousands Of Entries Over Internet. This Could Take Several Minutes. During That Time The Monitored Script Will Be Unable To Update Its Transcript Or Log File. If The Threshold Is Less Than The Time Required For The Next Update, The Monitoring CmdLet Will Wrongly Identify The Monitored Script As Failed And Depending Of The Specified Parameters Might Restart The Script In The Middle Of The Task.</maml:para>
          </maml:description>
          <command:parameterValue required="true">int</command:parameterValue>
          <dev:type>
            <maml:name>System.Int32</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>15</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <!-- Parameter: Path -->
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>Path</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>FilePath</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>TranscriptFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" globbing="false" pipelineInput="false" position="named" aliases="FilePath,TranscriptFile,LogFile">
        <maml:name>LogFile</maml:name>
        <maml:description>
          <maml:para>Specifies The Full Absolute UNC File Path To The Monitored Script Transcript File</maml:para>
          <maml:para>This is an alias of the Path parameter.</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <!-- Parameter: ScheduledTask -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>ScheduledTask</maml:name>
        <maml:description>
          <maml:para>Specifies The Path To The Monitored Script Windows Scheduled Task</maml:para>
          <maml:para>If Omitted The CmdLet Will Try To Auto Generate It</maml:para>
          <maml:para>If Auto Generation Fail And The Monitoring Entry Is Created Without Scheduled Task</maml:para>
          <maml:para>The Monitoring CmdLet Will Not Attempt To Restart The Script In Case The Script Fail</maml:para>
        </maml:description>
        <command:parameterValue required="true">string</command:parameterValue>
        <dev:type>
          <maml:name>System.String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue></dev:defaultValue>
      </command:parameter>
      <!-- Parameter: Threshold -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>Threshold</maml:name>
        <maml:description>
          <maml:para>Specifies The Script Inactivity Threshold In Minutes</maml:para>
          <maml:para>Valid Range From 1 To 1440</maml:para>
          <maml:para>The Threshold Have To Be Specified Carefully. It Might Happen That The Monitored Script Makes Some Heavy Tasks Against Remote Location. Like For Example To Get Azure Logs With Thousands Of Entries Over Internet. This Could Take Several Minutes. During That Time The Monitored Script Will Be Unable To Update Its Transcript Or Log File. If The Threshold Is Less Than The Time Required For The Next Update, The Monitoring CmdLet Will Wrongly Identify The Monitored Script As Failed And Depending Of The Specified Parameters Might Restart The Script In The Middle Of The Task.</maml:para>
        </maml:description>
        <command:parameterValue required="true">int</command:parameterValue>
        <dev:type>
          <maml:name>System.Int32</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>15</dev:defaultValue>
      </command:parameter>
      <!-- Parameter: PassThru -->
      <command:parameter required="false" globbing="false" pipelineInput="false" position="named">
        <maml:name>PassThru</maml:name>
        <maml:description>
          <maml:para>Specifies To The CmdLet To Revert A PSCustomObject With The Monitoring Entry</maml:para>
        </maml:description>
        <command:parameterValue required="true">SwitchParameter</command:parameterValue>
        <dev:type>
          <maml:name>System.Management.Automation.SwitchParameter</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>False</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes />
    <command:returnValues>
      <!-- OutputType: MonitoringEntry -->
      <command:returnValue>
        <dev:type>
          <maml:name>SnsPsScriptsMonitoring.MonitoringEntry</maml:name>
          <maml:uri />
        </dev:type>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:title></maml:title>
      <maml:alert>
        <maml:para>AUTHOR: Svetoslav Nedyalkov Savov (svesavov@hotmail.com)</maml:para>
        <maml:para>THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK</maml:para>
        <maml:para>OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>---------- EXAMPLE 1 ----------</maml:title>
        <dev:code>Enable-SnsScriptMonitoring -Path "C:\Transcript.txt" -ScheduledTask "\MyScript" -Threshold 30;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 2 ----------</maml:title>
        <dev:code>[SnsPsScriptsMonitoring.MonitoringEntry]$objEntry = Enable-SnsScriptMonitoring -Path "C:\Transcript.txt" `
-ScheduledTask "\MyScript" -Threshold 30 -PassThru;</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText> svesavov / SnsPsScriptsMonitoring - </maml:linkText>
        <maml:uri>https://github.com/svesavov/SnsPsScriptsMonitoring</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> PowerShell Gallery - </maml:linkText>
        <maml:uri>https://www.powershellgallery.com/packages/SnsPsScriptsMonitoring/</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> Svetoslav Savov on LinkedIn - </maml:linkText>
        <maml:uri>https://www.linkedin.com/in/svetoslavsavov</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText> SQLite V3 - </maml:linkText>
        <maml:uri>https://sqlite.org/index.html</maml:uri>
      </maml:navigationLink>
    </maml:relatedLinks>
  </command:command>
</helpItems>