PowerShell / Crescendo

a module for wrapping native applications in a PowerShell function and module
MIT License
399 stars 37 forks source link

Ordered combined commands #196

Open DennisL68 opened 1 year ago

DennisL68 commented 1 year ago

Summary of the new feature / enhancement

When using PSconfig.exe with SharePoint, providing several commands in sequence I must make sure they are specified in the correct order (or combine them in one go) to make sure each command is run successfully.

The required sequence for PSConfig has to be

  1. -cmd configdb
  2. -cmd helpcollections
  3. -cmd secureresources
  4. -cmd services
  5. -cmd installfeatures
  6. -cmd adminvs
  7. -cmd evalprovision (only for stand-alone installations)
  8. -cmd applicationcontent
  9. -cmd upgrade

(You can also find it on [Psconfig command-line reference (SharePoint Server 2010)}(https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-server-2010/cc263093(v=office.14)?redirectedfrom=MSDN)

Now, I could of course start permutating all possible command combinations and specify one super command set per permutation, but that would be a lot.

Proposed technical implementation details (optional)

Currently, one OriginalCommandElements set is possible per Command. This can then be added upon with params. But this can't be expanded to include several "commands", only single word parameters.

So if I need to run the PSConfig command combo

PSConfig.exe -cmd upgrade -inplace b2b -wait -force -cmd applicationcontent -install -cmd installfeatures

I would either have to build one superset (of very many)

 "Commands": [
    {
      "Verb": "Invoke",
      "Noun": "PSConfigUpgrade",
      "OriginalName": "psconfig.exe",
      "OriginalCommandElements": [
        "-cmd", "upgrade","-inplace","b2b",
        "-cmd", "applicationcontent","-install",
        "-cmd","installfeatures"
      ]
  }
]

or three separat commands (remembering by heart, which order to use them)

 "Commands": [
    {
      "Verb": "Invoke",
      "Noun": "PSConfigProdcustUpgrade",
      "OriginalName": "psconfig.exe",
      "OriginalCommandElements": [
        "-cmd", "upgrade"
      ],
"Parameters": [
        {
          "Name":           "Inplace",
          "OriginalName":   "-inplace",
          "ParameterType":  "string"
        }
  },
{
      "Verb": "Invoke",
      "Noun": "PSConfigInstallApplication",
      "OriginalName": "psconfig.exe",
      "OriginalCommandElements": [
        "-cmd", "applicationcontent","-install"
      ]
  },
{
      "Verb": "Invoke",
      "Noun": "PSConfigRegister",
      "OriginalName": "psconfig.exe",
      "OriginalCommandElements": [
        "-cmd", "installfeatures"
      ]
]

Would a feature allowing an array of arguments for one parameter along with an ParamterOrder value be able to solve this?