0

I am currently configuring a CD Server and a CM server but looking at the spreadsheet (downloaded from the official site: https://doc.sitecore.net/sitecore_experience_platform/82/setting_up_and_maintaining/xdb/configuring_servers/configure_a_content_management_server) and checking the Sitecore's file extension one by one is really exhausting.

Is there any way to make this easy? I first thought of PowerShell but the spreadsheet's format is just not helpful enough to code them.

1

I had used a console app which allowed me to change the file name. Below is the code snippet of the console app

public static void UpdateConfigs()
{
    var filesWithPath = DirSearch(@"C:\path\to\app config folder\Include");

    string[] configNames = File.ReadAllLines(@"C:\Users\username\Desktop\Enable Configs.txt");

    var counter = 0;

    foreach (var configName in configNames)
    {
        if (filesWithPath.ContainsKey(configName))
        {
            Console.WriteLine($"Changing {configName}");
            File.Move(filesWithPath[configName], Path.ChangeExtension(filesWithPath[configName], ".disabled"));

            counter++;
        }
    }

    Console.WriteLine();
    Console.WriteLine($"Total: {counter}");

    Console.WriteLine("Press any key to exit.");
    Console.ReadKey();
}

private static Dictionary<string, string> DirSearch(string sDir)
{
    var files = new Dictionary<string, string>();

    foreach (string f in Directory.GetFiles(sDir))
    {
        files.Add(Path.GetFileName(f), f);
    }

    foreach (string d in Directory.GetDirectories(sDir))
    {
        DirSearch(d);
    }

    return files;
}

The Enable Config is only 1 column. You just need to copy all the names from the header Config file name. Below is an example of the text file entries

enter image description here

You just need to update the .disabled. Follow the below steps

  1. If you are disabling configs, filter the excel sheet and set it to disabled.

  2. Copy the names from the Config file name and paste it into the text file.

  3. Execute the code.

Note

You need to change the .disabled to blank if you need to enable the config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.