public void SetProperty(string path, PSObject propertyToSet) { try { var item = GetDynamicItem(path); if (propertyToSet == null) { throw new ArgumentNullException("Property not defined"); } LogInfo("Executing SetProperty(string path='{0}', PSObject propertyToSet='{1}')", path, propertyToSet); if (item != null) { item.Edit(args => { item.Fields.ReadAll(); var asDict = propertyToSet.BaseObject() as IDictionary; if (asDict != null) { foreach (var key in asDict.Keys) { SetItemPropertyValue(path, item, key.ToString(), asDict[key]); } } else { foreach (PSPropertyInfo property in propertyToSet.Properties) { SetItemPropertyValue(path, item, property.Name, property.Value); } } WriteItem(item); }); } } catch (Exception ex) { LogUtils.Error($"Error while executing GetProperty(string path='{path}', PSObject propertyValue)", ex); throw; } }