So.. very odd problem.
Using VS2015 and .net 4.52
I developed this C# powershell code, it is running a script and catches the output. like this:
using (PowerShell powerShellInstance = PowerShell.Create())
{
powerShellInstance.AddScript(scriptContents);
Collection<PSObject> PSOutput = powerShellInstance.Invoke();
if (powerShellInstance.Streams.Information.Count > 0)
{
foreach (var item in powerShellInstance.Streams.Information)
{
//do something with info
}
}
}
}
Compiles and runs (on a Windows 10 pro machine), no problems.
Until I got a new machine (surface pro 4, so also windows 10 pro) and tried to compile the code, I get this error:
'PSDataStreams' does not contain a definition for 'Information' and no extension method 'Information' accepting a first argument of type 'PSDataStreams' could be found (are you missing a using directive or an assembly reference?)
This is all TFS based, so I'm sure it is the same code.
If I goto definition on the two machines the problem becomes obvious:
So, I commented out the not compiling code and ran it, to see what was happening runtime:
So the property IS there.. Anybody got a good explanation for this?
BTW: the msdn documentation does not mention an Information property..