Get-DbaDiskSpace - Make Unit work and clean up the two other dead parameters - #10611
Open
andreasjordan wants to merge 1 commit into
Open
Get-DbaDiskSpace - Make Unit work and clean up the two other dead parameters#10611andreasjordan wants to merge 1 commit into
andreasjordan wants to merge 1 commit into
Conversation
…ameters Unit was deprecated in 2017 when the output became Size objects, but the parameter, its default and its examples all survived, so -Unit MB silently returned the same display as no parameter at all. The Size objects have a per-object display style, so Unit now sets that style on Capacity and Free: the display follows the requested unit and the underlying values are unchanged. PB is dropped from the ValidateSet because the SizeStyle enum does not offer it, and the never-applied GB default is dropped so the default display stays dynamic. SqlCredential lost its only consumer when CheckForSql was removed in 2019 (#5023) and is removed; a warning instead would fire for everyone who sets a wildcard *:SqlCredential default. CheckFragmentation lost its implementation in the 2017 rewrite and now stops with a message, following the Get-DbaDbBackupHistory -AgCheck precedent. Found via static analysis by @greenmtnsun in #10607. (do Get-DbaDiskSpace)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three parameters of
Get-DbaDiskSpacewere declared, documented with examples, and never read:-Unitwas deprecated in the 2017 rewrite (when the output became self-formattingSizeobjects), but the parameter, itsGBdefault and its help examples all survived, so-Unit MBsilently returned the same display as no parameter at all.-SqlCredentiallost its only consumer when-CheckForSqlwas removed in 2019 (get-dbadiskspace -checksql needs some tlc #5023).-CheckFragmentationlost its DefragAnalysis implementation in the same 2017 rewrite.What changed
-Unitnow works. TheSizetype has a writable per-object display style, so the command sets it onCapacityandFreewhen-Unitis bound:-Unit MBdisplays1,907,348.63 MBwhere the default displays1.82 TB. The underlying values are unchanged and allSizeIn*/FreeIn*properties remain available.PBis dropped from the ValidateSet because theSizeStyleenum does not offer it, and the never-appliedGBdefault is dropped so the default display stays dynamic — both exactly as the command has actually behaved for nine years.-SqlCredentialis removed. A deprecation warning was not an option here: the test guide and many environments set a wildcard*:SqlCredentialdefault via$PSDefaultParameterValues, which binds the parameter on every call and would warn for everyone.-CheckFragmentationstops with a message (theGet-DbaDbBackupHistory -AgCheckprecedent), since silently returning results without the requested fragmentation data misleads the caller.Help and
.OUTPUTSupdated accordingly.Tests
Parameter validation updated; new tests assert
-Unit MBchanges the displayed unit without changing the values, and that-CheckFragmentationreturns nothing and warns. Verified locally: all three fail against the old code (-Unit MBdisplaying49.47 GBis exactly the reported symptom) and the file passes 6/6 with the fix.Found by @greenmtnsun via static analysis, reported in #10607.
🤖 Generated with Claude Code