Skip to content

Commit 967461a

Browse files
author
quoctruong
committed
Fix Session State Error
1 parent fe4bf82 commit 967461a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Rules/AvoidUsingDeprecatedManifestFields.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4141

4242
if (String.Equals(System.IO.Path.GetExtension(fileName), ".psd1", StringComparison.OrdinalIgnoreCase))
4343
{
44-
var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
44+
var ps = System.Management.Automation.PowerShell.Create();
4545
IEnumerable<PSObject> result = null;
4646
try
4747
{
@@ -73,6 +73,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
7373
}
7474
}
7575

76+
ps.Dispose();
7677
}
7778

7879
}

Rules/MissingModuleManifestField.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
3838

3939
if (String.Equals(System.IO.Path.GetExtension(fileName), ".psd1", StringComparison.OrdinalIgnoreCase))
4040
{
41-
var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
41+
var ps = System.Management.Automation.PowerShell.Create();
4242

4343
try
4444
{
@@ -68,6 +68,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
6868
}
6969
}
7070

71+
ps.Dispose();
7172
}
7273

7374
}

0 commit comments

Comments
 (0)