Given the context on the last few posts. I've made a simple helper method in C# that can take a simple powershell hashtable and create a PSCustomObject based on it. Here is an example of how you can call it.
[snapinini.newobjecthelper]::newObjectFast(@{name="karl";age=31;now = [datetime]::Now})
very simple and its at least 6 times faster than the closest other technique in powershell. Most of hte overhead is in creating the hashtable. (otherwise its 90 times faster). The hashtable syntax is very convenient however maybe even its overhead is too much and we deserve a better way.
Here is the C# method. Its pretty basic stuff.
public static PSObject newObjectFast( Hashtable noteproperties )
{
PSObject obj = new PSObject();
if (noteproperties != null)
foreach(DictionaryEntry item in noteproperties)
obj.Properties.Add(new PSNoteProperty((string)item.Key,item.Value));
return obj;
}
- Karl