beatcracker / VSCELicense

PowerShell module to get and set Visual Studio Community Edition license expiration date in registry
Microsoft Public License
304 stars 95 forks source link

The licenser does not detect a module. CMD runned as admin in Windows 11 #21

Closed dvdvideo1234 closed 9 months ago

dvdvideo1234 commented 1 year ago
F:\GIT\VSCELicense>PowerShell.exe Import-Module -Name 'VSCELicense.psd1'
Import-Module : The specified module 'VSCELicense.psd1' was not loaded because no valid module file was found in any mo
dule directory.
At line:1 char:1
+ Import-Module -Name 'VSCELicense.psd1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (VSCELicense.psd1:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
beatcracker commented 9 months ago

When only module name is specified, the PowerShell will try to import it from the installed modules, and not from the local file. You need to use './VSCELicense.psd1'. If you want to use module unattended, the command would look like this:

PowerShell.exe -Command "Import-Module -Name './VSCELicense.psd1' ; Get-VSCELicenseExpirationDate"

See usage docs: https://github.com/beatcracker/VSCELicense?tab=readme-ov-file#usage