Change PowerShell parameters from dictionary to list of strings in C# method

I have a method to call a PowerShell command along with parameters. I have defined it like this:

public string RunScript(string contentScript, Dictionary<string, EntityProperty> parameters)
    {
        using (PowerShell ps = PowerShell.Create())
        {
            ps.AddScript(contentScript);
            ps.AddParameters(parameters);

My PowerShell command parameter is defined like this:

[Parameter]
public List<string> Properties { get; set; } = new List<string>();

How do I change my RunScript method so that in parameters I take only the list of strings which is passed?



Read more here: https://stackoverflow.com/questions/66276748/change-powershell-parameters-from-dictionary-to-list-of-strings-in-c-sharp-metho

Content Attribution

This content was originally published by ZZZSharePoint at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: