Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.120 #2828

Merged
merged 44 commits into from
Dec 11, 2017
Merged

0.9.120 #2828

Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
054f654
Merge pull request #2 from sqlcollaborative/development
olegstrutinskii Dec 7, 2017
746841c
Users parameter was being reset
ClaudioESSilva Dec 7, 2017
d7fdf16
Touch Invoke-DbaDatabaseShrink
olegstrutinskii Dec 7, 2017
e9af825
Touchup Set-DbaMaxDop
ClaudioESSilva Dec 7, 2017
36f4895
Add Pester tests
ClaudioESSilva Dec 7, 2017
682e588
Fixing weird bug with timeoutassigment
olegstrutinskii Dec 8, 2017
4b6f7f5
Small parameter description change
olegstrutinskii Dec 8, 2017
73c551d
New command
Dec 8, 2017
57f9179
Fixed some docs
Dec 8, 2017
14a5970
Added validation tags for 1.0
Dec 8, 2017
e8c7e24
touchup help, add new parameters and examples
wsmelton Dec 9, 2017
d420d59
Adjust parameter block, add new params
wsmelton Dec 9, 2017
8f0d096
Logic to allow filtering events and file type
wsmelton Dec 9, 2017
8d3d82f
hiding output of array add method
wsmelton Dec 9, 2017
2dc2e8a
cleanup few items add validation tags
wsmelton Dec 9, 2017
ed2efe7
sneak in a hidden window
potatoqualitee Dec 9, 2017
d1eab85
Removed conflicting alias
Dec 9, 2017
ce52252
fixed help
Dec 9, 2017
0d990ee
Fixed CBH Parameter
Dec 10, 2017
7e0a295
Switched to using Invoke-Sqlcmd2
Dec 10, 2017
f35ca77
set parameters offline
Stuart-Moore Dec 10, 2017
6ba0105
Added examples and on offline switch
Stuart-Moore Dec 11, 2017
52539cb
switching Force for TrustPath
Stuart-Moore Dec 11, 2017
e6dbd69
Test-DbaMaxDop returns duplicate results
ClaudioESSilva Dec 11, 2017
69da125
Revert "Test-DbaMaxDop returns duplicate results"
ClaudioESSilva Dec 11, 2017
b629cc8
Output as soon as we create the object
ClaudioESSilva Dec 11, 2017
53b3831
Improving CBH based on user feedback
Stuart-Moore Dec 11, 2017
b7d0359
Added Tests for Test-DbaMaxDop
ClaudioESSilva Dec 11, 2017
bc9261f
Close curly bracket
ClaudioESSilva Dec 11, 2017
4257c2d
Add -WhatIf & -Confirm help
ClaudioESSilva Dec 11, 2017
440761e
Improve validation
ClaudioESSilva Dec 11, 2017
e661c38
Keep only Stop-Function
ClaudioESSilva Dec 11, 2017
46b2f6e
Fix column name TotalCount to Count
ClaudioESSilva Dec 11, 2017
ebc9d9e
Add new test
ClaudioESSilva Dec 11, 2017
94159bb
Merge pull request #2825 from sqlcollaborative/MaxDopCommands
potatoqualitee Dec 11, 2017
0b8661d
Merge pull request #2823 from sqlcollaborative/offlinestartupparams
potatoqualitee Dec 11, 2017
4d2f3dd
Merge pull request #2821 from sqlcollaborative/Invoke-DbaSqlCmd
potatoqualitee Dec 11, 2017
f266b28
Merge pull request #2820 from wsmelton/improve-FindDbaDatabaseGrowthE…
potatoqualitee Dec 11, 2017
c4ab646
Merge pull request #2813 from Zhunya/touch_InvokeDbShrink
potatoqualitee Dec 11, 2017
b7c5e59
Merge pull request #2827 from sqlcollaborative/Fix_Test-DbaVirtualLof…
potatoqualitee Dec 11, 2017
cf68514
Merge pull request #2810 from sqlcollaborative/Fix_DbaOrphanUsers_-Us…
potatoqualitee Dec 11, 2017
f600ce1
Merge remote-tracking branch 'refs/remotes/origin/master' into develo…
potatoqualitee Dec 11, 2017
3f7b2f3
Merge branch 'development' of https://github.com/sqlcollaborative/dba…
potatoqualitee Dec 11, 2017
91d12b5
0.9.120
potatoqualitee Dec 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Users parameter was being reset
Added different variable to get users to work
  • Loading branch information
ClaudioESSilva committed Dec 7, 2017
commit 746841c5a9d76df4de0e8e1a72acd9ef003c3632
21 changes: 11 additions & 10 deletions functions/Repair-DbaOrphanUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Repair-DbaOrphanUser {

.PARAMETER SqlInstance
The SQL Server Instance to connect to.

.PARAMETER SqlCredential
Allows you to login to servers using SQL Logins instead of Windows Authentication (AKA Integrated or Trusted). To use:

Expand Down Expand Up @@ -45,7 +45,7 @@ function Repair-DbaOrphanUser {
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

.EXAMPLE
Repair-DbaOrphanUser -SqlInstance sql2005

Expand Down Expand Up @@ -103,7 +103,7 @@ function Repair-DbaOrphanUser {
process {
$start = [System.Diagnostics.Stopwatch]::StartNew()
foreach ($instance in $SqlInstance) {

try {
Write-Message -Level Verbose -Message "Connecting to $instance."
$server = Connect-SqlInstance -SqlInstance $instance -SqlCredential $SqlCredential
Expand Down Expand Up @@ -142,23 +142,23 @@ function Repair-DbaOrphanUser {

if ($Users.Count -eq 0) {
#the third validation will remove from list sql users without login. The rule here is Sid with length higher than 16
$Users = $db.Users | Where-Object { $_.Login -eq "" -and ($_.ID -gt 4) -and ($_.Sid.Length -gt 16 -and $_.LoginType -eq [Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin) -eq $false }
$UsersToWork = $db.Users | Where-Object { $_.Login -eq "" -and ($_.ID -gt 4) -and ($_.Sid.Length -gt 16 -and $_.LoginType -eq [Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin) -eq $false }
}
else {
if ($pipedatabase.Length -gt 0) {
$Source = $pipedatabase[3].parent.name
$Users = $pipedatabase.name
$UsersToWork = $pipedatabase.name
}
else {
#the fourth validation will remove from list sql users without login. The rule here is Sid with length higher than 16
$Users = $db.Users | Where-Object { $_.Login -eq "" -and ($_.ID -gt 4) -and ($Users -contains $_.Name) -and (($_.Sid.Length -gt 16 -and $_.LoginType -eq [Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin) -eq $false) }
$UsersToWork = $db.Users | Where-Object { $_.Login -eq "" -and ($_.ID -gt 4) -and ($Users -contains $_.Name) -and (($_.Sid.Length -gt 16 -and $_.LoginType -eq [Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin) -eq $false) }
}
}

if ($Users.Count -gt 0) {
if ($UsersToWork.Count -gt 0) {
Write-Message -Level Verbose -Message "Orphan users found"
$UsersToRemove = @()
foreach ($User in $Users) {
foreach ($User in $UsersToWork) {
$ExistLogin = $server.logins | Where-Object {
$_.Isdisabled -eq $False -and
$_.IsSystemObject -eq $False -and
Expand Down Expand Up @@ -215,7 +215,7 @@ function Repair-DbaOrphanUser {
Write-Message -Level Verbose -Message "No orphan users found on database '$db'."
}
#reset collection
$Users = $null
$UsersToWork = $null
}
catch {
Stop-Function -Message $_ -Continue
Expand All @@ -229,8 +229,9 @@ function Repair-DbaOrphanUser {
}
end {
$totaltime = ($start.Elapsed)
$start.Stop()
Write-Message -Level Verbose -Message "Total Elapsed time: $totaltime."

Test-DbaDeprecation -DeprecatedOn "1.0.0" -EnableException:$false -Alias Repair-SqlOrphanUser
}
}
}