private void EachPowerShellSection(ref int collections, string server, ref long fileMilliSeconds, string filename, IniFile.IniFile ini) { foreach (var section in ini.GetSection("*")) { if (section.Equals("cimcollect")) { continue; // ignore sample section } collections++; var iniCollect = ini.GetValue(section, "cimcollect", "yes"); if ("0fn".ToLower().Contains((iniCollect + "Y").Substring(0, 1).ToLower())) { continue; } var iniName = ini.GetValue(section, "name", "name"); var s = ini.GetAllValues(section, "s"); var ps = ini.GetAllValues(section, "powershell"); var query = ((null == ps) ? "" : String.Join(" ", ps)) + ((null == s) ? "" : String.Join(Environment.NewLine, s)); bool result = false; if (!String.IsNullOrWhiteSpace(query)) { result = RunPowerShellQuery(server, ref fileMilliSeconds, filename, section, iniName, query); } } }
// part 1 - save all file sections for processing all at once into List<FileSetup>() FileSetupList; public static void EachFileSection(ref int collections, string server, string filename, IniFile.IniFile ini) { Server = server; var iniFileName = ini.TheFile; foreach (var section in ini.GetSection("*", "File")) { if (section.Equals("cimcollect")) { continue; // ignore sample section } collections++; var iniCollect = ini.GetValue(section, "cimcollect", "yes"); if ("0fn".ToLower().Contains((iniCollect + "Y").Substring(0, 1).ToLower())) { continue; } var fileToCopyName = ini.GetValue(section, "File"); if (!String.IsNullOrWhiteSpace(fileToCopyName)) { var trimword = ini.GetValue(section, "Trim", "None").ToLower(); var trimval = trimword.StartsWith("a") ? FileSetup.LineTrimming.All : trimword.StartsWith("e") ? FileSetup.LineTrimming.Edge : FileSetup.LineTrimming.None; FileSetupList.Add(new FileSetup() { IniFileName = iniFileName, SectionName = section, CommentMark = ini.GetValue(section, "Comment", ""), FileMissing = ini.GetValue(section, "Missing", "***no file***"), FilePath = fileToCopyName, // ini.GetValue(section, "File",""), TrimOptions = trimval }); } } }