SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 67 forks source link

Add "Remove-PSGSuiteConfig" Cmdlet to remove configurations that are no longer valid? #293

Open jeffreymcclain opened 4 years ago

jeffreymcclain commented 4 years ago

Is your feature request related to a problem? Please describe. There doesn't appear to be an easy way to remove configurations that are no longer valid. I was testing out several different configurations and wanted to cleanup the older ones.

Describe the solution you'd like I'd like a cmdlet to remove previous configurations that are no longer desired.

Describe alternatives you've considered I could try to delete the file where the configurations are stored manually, but I'm not sure where it's located or if there would be any unintended consequences. I tried uninstalling and reinstalling the Configuration and PSGSuite modules, but the configurations are still shown when running "Get-PSGSuiteConfig -PassThru".

jeffreymcclain commented 4 years ago

Edit: On a different note, for Set-PSGSuiteConfig I tried setting the "Scope" parameter to "Machine", but the configuration still wasn't accessible from other user accounts on the same machine.

This might just be because I simply used a variation of the example command from the "Initial Setup" guide, rather than using an AES key as explained in the "Multiple Configurations" section.

Set-PSGSuiteConfig -ConfigName MyConfig -SetAsDefaultConfig -ClientSecretsPath $ClientSecretsPath -AdminEmail $AdminEmail -Scope Machine
FISHMANPET commented 3 years ago

User configurations are stored at ~\AppData\Local\powershell\SCRT HQ\PSGSuite\Configuration.psd1 (on Windows at least), there's no harm in editing that file, it's just a hashtable of hashtables. As long as you're only removing hashtables and not modifying them you should be fine. For example take this trivial config:

@{
  config1 = @{
    #stuff goes here
  }
  config2 = @{
    #different stuff here
  }
  DefaultConfig = 'config2'
}

If you want to remove config1 you'd just remove that element of the hash table so it would look like this:

@{
  config2 = @{
    #different stuff here
  }
  DefaultConfig = 'config2'
}

How are you importing the config with other users? When you use a machine config you have to specify that you're using a machine config. I use this command in some scripts of mine to load a config: Get-PSGSuiteConfig -ConfigName 'sharedConfig' -Scope Machine