Update-sqmModule
sqmTool Config
sqmSQLTool v1.0.0+ · Update
✓ -WhatIf supported
Install-Module), GitHub (the release ZIP of the repository) and UNC / LocalDir (copying the files from a share or a folder).
Without parameters it calls
Test-sqmModuleUpdate itself. If the last source is not reachable, that check falls back through PSGallery, GitHub and the configured update repository. With -UpdateInfo (the result of that check) it skips the check.
Version folders. If the module sits in a version folder (
...\Modules\sqmSQLTool\1.9.140.0, the way Install-Module places it), the new version is not copied into it, because folder name and ModuleVersion would no longer match and PowerShell would not find the module. A sibling folder with the new version number is created and the old version stays untouched next to it. A backup is only made for a flat folder.
Rights. An AllUsers installation under Program Files needs administrator rights. The function checks that up front and stops with a warning instead of failing in the middle of copying. The new version applies from the next PowerShell session or after
Import-Module sqmSQLTool -Force.
At module start the same function can run on its own:
UpdateMode Prompt (default) offers a newer version, Auto installs it without asking, Off does not check.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -UpdateInfo | hashtable | Optional | Test-sqmModuleUpdate | Result of Test-sqmModuleUpdate (Source, Version, Path). Without it the check runs inside the function. |
| -Credential | PSCredential | Optional | , | Credentials for UNC shares. |
| -Backup | switch | Switch | $true | Back up the module folder to %TEMP% before a file update. Not needed (and not done) for version folders. |
| -Force | switch | Switch | $false | Update even if no newer version was found. |
| -WhatIf / -Confirm | switch | Optional | , | Shows which source and target would be used. |
Execution Flow
Return value
No return object. The function writes status lines to the host (green: updated, gray: backup path, yellow: when the new version applies) and sets $env:SQMSQLTOOL_UPDATED to the new version (or unknown), which the GUI launcher and the start check use to reload the module.
| Situation | Result |
|---|---|
No newer version and no -Force | Message with the installed version, nothing changes. |
| Module folder not writable | Warning that administrator rights are needed. Nothing is changed. |
| PSGallery update fails | Warning with the reason; nothing else is tried. |
| UNC / LocalDir: no source known or not reachable | Warning (no install source and no UpdateRepository set, or the path is unreachable). |
| Any error while copying | Error "Update fehlgeschlagen" with the reason. |
Defaults: the GitHub repository is JankeUwe/sqmSQLTool. For UNC sources the path comes from the check, from the stored install source or from the configured UpdateRepository.
Examples
Check the install source and install a newer version if there is one
Update-sqmModule
Show what would be done
Update-sqmModule -WhatIf
Reinstall the current version from the source
Update-sqmModule -Force
Check first, then update with the result
$info = Test-sqmModuleUpdate
if ($info) { Update-sqmModule -UpdateInfo $info }Load the new version in the current session
Update-sqmModule Import-Module sqmSQLTool -Force