Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-Type 'DateTime' not recognized #206

Open
Rtw915 opened this issue Dec 18, 2019 · 0 comments
Open

Add-Type 'DateTime' not recognized #206

Rtw915 opened this issue Dec 18, 2019 · 0 comments

Comments

@Rtw915
Copy link

Rtw915 commented Dec 18, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant