proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
541 stars 87 forks source link

Add-Type 'DateTime' not recognized #206

Open Rtw915 opened 4 years ago

Rtw915 commented 4 years ago

I think it is a bug

I have a script that run fine in ISE or the console but would not run in PRTG.

in PRTG it would output this in the log file:


(1) :     using System;
At C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\1.7.4.4\PoshRSJob.psm1:51 char:5
+     Add-Type @"
+     ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerErro 
   r) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

WARNING: (0) : No source files specified

(1) :     using System;
Add-Type : Cannot add type. Compilation errors occurred.
At C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\1.7.4.4\PoshRSJob.psm1:51 char:5
+     Add-Type @"
+     ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException
    + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand

Unable to find type [RSJob].
At C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\1.7.4.4\Public\Get-RSJob.ps1:72 char:9
+         [RSJob[]]$Job,
+         ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (RSJob:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Unable to find type [RSJob].
At C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\1.7.4.4\Public\Get-RSJob.ps1:72 char:9
+         [RSJob[]]$Job,
+         ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (RSJob:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

After searching for the issue I found this: https://social.technet.microsoft.com/Forums/windows/en-US/c8467128-ab64-4920-8697-3cc76e901568/addtype-usage?forum=winserverpowershell

In PoshRSJob.psm1 I changed line 72 from:

public DateTime LastActivity = DateTime.MinValue; to public System.DateTime LastActivity = System.DateTime.MinValue;

It now appears to work.