parm($directory) $Count = (get-childitem $directory).Count $api = new-object -comObject "MOM.ScriptAPI" $bag = $api.CreatePropertyBag() $bag.AddValue('FileCount',$Count) $bag