This file contains 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
ForEach ($Select in $Selected) | |
{ | |
$Type = [int](-not $Database) | |
$Name = (Invoke-SQLQuery -Instance $Instance -Database Master -MultiSubnetFailover -Query "Select name From sys.master_files Where database_id = '$($Select.ID)' And type = $Type").Name | |
If ($Name) | |
{ | |
Write-Verbose "$(Get-Date): Shrinking $($Select.Name) database/log file: $Name" | |
$Result = Invoke-SQLQuery -Instance $Instance -Database $Select.Name -MultiSubnetFailover -Query "DBCC SHRINKFILE($Name,1)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment