Skip to content

Deployment

Raymond Piller edited this page Jul 6, 2018 · 6 revisions

I decided to implement this via a Scheduled Task that we create via a GPO/GPP. In order to make this just works on any computer that gets the GPP, we need this to automatically install, update, and run. Here's the script I came up with to do just that:

$lm = 'LicenseManager'
$lmm = Get-Module $lm -ListAvailable
$flm = Find-Module $lm
if (-not $lmm) {
    Install-PackageProvider -Name 'NuGet' -MinimumVersion '2.8.5.201' -Force
    Install-Module $lm -Force
} elseif ($lmm.Version -ne $flm.Version) {
    Update-Module $lm -Force
    Get-Module $lm -ListAvailable | Where-Object { $_.Version -ne $flm.Version } | ForEach-Object { Uninstall-Module -Name $_.Name -RequiredVersion $_.Version -Force }
}
Import-Module $lm -Force
Invoke-LicenseManager

Of course, we need to turn that into a suitable command for use in a run command. So we make it a one-liner and call it like so:

powershell.exe -W H -Ex Bypass -NoP -NonI "$lm = 'LicenseManager'; $lmm = Get-Module $lm -ListAvailable; $flm = Find-Module $lm; if (-not $lmm) { Install-PackageProvider -Name 'NuGet' -MinimumVersion '2.8.5.201' -Force; Install-Module $lm -Force; } elseif ($lmm.Version -ne $flm.Version) { Update-Module $lm -Force; Get-Module $lm -ListAvailable | Where-Object { $_.Version -ne $flm.Version } | ForEach-Object { Uninstall-Module -Name $_.Name -RequiredVersion $_.Version -Force }; }; Import-Module $lm -Force; Invoke-LicenseManager"

Now just create a GPO that:

  • Created the LicenseManager environment variable.
  • Runs the above script via a scheduled task:
    • Trigger at Startup
    • Trigger every 15 minutes; don't allow a new instance if it's already running.

That's it! If you need more details, proceed to the next section.

GPO Details

If you want a ton of details about how to create the GPO, here you go ...

  • Computer Configuration
    • Windows Settings
      • Environment Variable
        • License Manager (Order: 1)
          • General
            • Action: Replace
            • Properties
              • Context: System
              • Variable: LicenseManager
              • Context: {"Processes": {"notepad.exe":3, "Calculator.exe":10}, "DirectoryPath":"\\\\license\\LicenseManager"}
          • Common
            • Options
              • Stop processing items on this extension if an error occurs on this item: No
              • Remove this item when it is no longer applied: Yes
    • Control Panel Settings
      • Scheduled Tasks
        • Scheduled Task (At least Windows 7) (Name: UNT-CAS LicenseManager)
          • UNT-CAS LicenseManager (Order: 1)
            • General
              • Action: Replace
              • Task
                • Name: UNT-CAS LicenseManager
                • Description: UNT-CAS LicenseManager
                • Run only when user is logged on: S4U
                • UserId: NT AUTHORITY\System
                • Run with highest privileges: HighestAvailable
                • Hidden: Yes
                • Configure for: 1.3
                • Enabled: Yes
              • Triggers
                1. At startup
                  • Enabled: Yes
                2. Daily
                  • Repeat task every 15 minutes for a duration of 1 day
                  • Stop all running tasks at end of repetition duration: No
                  • Activate: 7/5/2018 12:01:00 AM
                  • Synchronize across time zones: No
                  • Enabled: Yes
                  • Recur every 1 days
              • Actions
                1. Start a program
                  • Program/script: powershell.exe
                  • Arguments: -W H -Ex Bypass -NoP -NonI "$lm = 'LicenseManager'; $lmm = Get-Module $lm -ListAvailable; $flm = Find-Module $lm; if (-not $lmm) { Install-PackageProvider -Name 'NuGet' -MinimumVersion '2.8.5.201' -Force; Install-Module $lm -Force; } elseif ($lmm.Version -ne $flm.Version) { Update-Module $lm -Force; Get-Module $lm -ListAvailable | Where-Object { $_.Version -ne $flm.Version } | ForEach-Object { Uninstall-Module -Name $_.Name -RequiredVersion $_.Version -Force }; }; Import-Module $lm -Force; Invoke-LicenseManager"
              • Settings
                • Stop if the computer ceases to be idle: No
                • Restart if the idle state resumes: No
                • Start the task only if the computer is on AC power: No
                • Stop if the computer switches to battery power: No
                • Start only if the following network connection is available: Any connection
                • Allow task to be run on demand: Yes
                • Run task as soon as possible after a scheduled start is missed: Yes
                • If the task fails, restart every: 1 minute
                • Attempt to restart up to: 5
                • Stop task if it runs longer than: Immediately (aka Never)
                • If the running task does not end when requested, force it to stop: Yes
                • If the task is already running, then the following rule applies: IgnoreNew
            • Common
              • Options
                • Stop processing items on this extension if an error occurs on this item: No
                • Remove this item when it is no longer applied: Yes
Clone this wiki locally