Skip to content
Permalink
Browse files

1.0.64

  • Loading branch information...
potatoqualitee committed Nov 1, 2019
1 parent 200efab commit e91fbceb737e8b53f381ac25f748495ce3615108
Showing with 39 additions and 13 deletions.
  1. +36 −10 allcommands.ps1
  2. +1 −1 bin/dbatools-index.json
  3. +1 −1 dbatools.psd1
  4. +1 −1 en-us/dbatools-help.xml
$Priv = Invoke-Command2 -Raw -ComputerName $computer -Credential $Credential -ScriptBlock {
$temp = ([System.IO.Path]::GetTempPath()).TrimEnd(""); secedit /export /cfg $temp\secpolByDbatools.cfg > $NULL;
Get-Content $temp\secpolByDbatools.cfg | Where-Object {
$_ -match "SeBatchLogonRight" -or $_ -match 'SeManageVolumePrivilege' -or $_ -match 'SeLockMemoryPrivilege'
$_ -match "SeBatchLogonRight" -or
$_ -match 'SeManageVolumePrivilege' -or
$_ -match 'SeLockMemoryPrivilege' -or
$_ -match 'SeAuditPrivilege'
}
}
if ($Priv.count -eq 0) {
Write-Message -Level Verbose -Message "No users with Batch Logon, Instant File Initialization, or Lock Pages in Memory Rights on $computer"
Write-Message -Level Verbose -Message "No users with Batch Logon, Instant File Initialization, Lock Pages in Memory Rights, or Generate Security Audits on $computer"
}

Write-Message -Level Verbose -Message "Getting Batch Logon Privileges on $Computer"
if ($lpim.count -eq 0) {
Write-Message -Level Verbose -Message "No users with Lock Pages in Memory Rights on $computer"
}
$users = @() + $BL + $ifi + $lpim | Select-Object -Unique

Write-Message -Level Verbose -Message "Getting Generate Security Audits Privileges on $Computer"
$gsa = Invoke-Command2 -Raw -ComputerName $computer -Credential $Credential -ArgumentList $ResolveSID -ScriptBlock {
param ($ResolveSID)
. ([ScriptBlock]::Create($ResolveSID))
$temp = ([System.IO.Path]::GetTempPath()).TrimEnd("");
$gsaEntries = (Get-Content $temp\secpolByDbatools.cfg | Where-Object {
$_ -like 'SeAuditPrivilege*'
})

if ($null -ne $gsaEntries) {
$gsaEntries.substring(19).split(",").replace("`*", "") | ForEach-Object {
Convert-SIDToUserName -SID $_
}
}
} -ErrorAction SilentlyContinue

if ($gsa.count -eq 0) {
Write-Message -Level Verbose -Message "No users with Generate Security Audits Rights on $computer"
}
$users = @() + $BL + $ifi + $lpim + $gsa | Select-Object -Unique
$users | ForEach-Object {
[PSCustomObject]@{
ComputerName = $computer
User = $_
LogonAsBatch = $BL -contains $_
InstantFileInitialization = $ifi -contains $_
LockPagesInMemory = $lpim -contains $_
GenerateSecurityAudit = $gsa -contains $_
}
}
Write-Message -Level Verbose -Message "Removing secpol file on $computer"
}
}


#.ExternalHelp dbatools-Help.xml
function Get-DbaProcess {

Write-Message -Level Verbose -Message "Interpreting DMV Script Collections"

if (!$Path) {
$Path = "$script:PSModuleRoot\bin\diagnosticquery"
$Path = Join-Path -Path "$script:PSModuleRoot" -ChildPath "bin\diagnosticquery"
}

$scriptversions = @()
$scriptfiles = Get-ChildItem "$Path\SQLServerDiagnosticQueries_*_*.sql"
$scriptfiles = Get-ChildItem -Path "$Path\SQLServerDiagnosticQueries_*_*.sql"

if (!$scriptfiles) {
Write-Message -Level Warning -Message "Diagnostic scripts not found in $Path. Using the ones within the module."

$Path = "$base\bin\diagnosticquery"
$Path = Join-Path -Path $base -ChildPath "\bin\diagnosticquery"

$scriptfiles = Get-ChildItem "$base\bin\diagnosticquery\SQLServerDiagnosticQueries_*_*.sql"
if (!$scriptfiles) {
$glenberrysql = @()
$RssPostFilter = "SQL Server Diagnostic Information Queries for*"
$DropboxLinkFilter = "*dropbox.com*"
$LinkTitleFilter = "*Diagnostic*"
$LinkTitleFilter = "*Diagnostic Information Queries*"
$ExcludeSpreadsheet = "*BlankResutsSpreadsheet*"

foreach ($post in $Feed.item) {
if ($post.title -like $RssPostFilter) {
# We found the first post that matches it, lets go visit and scrape.
$page = Get-WebData -uri $post.link
$glenberrysql += ($page.Links | Where-Object { $_.href -like $DropboxLinkFilter -and $_.innerText -like $LinkTitleFilter } | ForEach-Object {
$glenberrysql += ($page.Links | Where-Object { $_.href -like $DropboxLinkFilter -and $_.outerHTML -like $LinkTitleFilter -and $_.outerHTML -notlike $ExcludeSpreadsheet } | ForEach-Object {
[pscustomobject]@{
URL = $_.href
SQLVersion = $_.innerText -replace " Diagnostic Information Queries", "" -replace "SQL Server ", "" -replace ' ', ''
SQLVersion = $_.outerHTML -replace "<.+`">", "" -replace "</a>", "" -replace " Diagnostic Information Queries", "" -replace "SQL Server ", "" -replace ' ', ''
FileYear = ($post.title -split " ")[-1]
FileMonth = "{0:00}" -f [int]([CultureInfo]::InvariantCulture.DateTimeFormat.MonthNames.IndexOf(($post.title -split " ")[-2]))
}
$link = $doc.URL.ToString().Replace('dl=0', 'dl=1')
Write-Message -Level Verbose -Message "Downloading $link)"
Write-ProgressHelper -Activity "Downloading Glenn Berry's most recent DMVs" -ExcludePercent -Message "Downloading $link" -StepNumber 1
$filename = "{0}\SQLServerDiagnosticQueries_{1}_{2}.sql" -f $Path, $doc.SQLVersion, "$($doc.FileYear)$($doc.FileMonth)"
$filename = Join-Path -Path $Path -ChildPath "SQLServerDiagnosticQueries_$($doc.SQLVersion)_$("$($doc.FileYear)$($doc.FileMonth)").sql"
Invoke-TlsWebRequest -Uri $link -OutFile $filename -ErrorAction Stop
Get-ChildItem -Path $filename
} catch {
},
{
"Name": "Get-DbaPrivilege",
"Description": "Gets the users with local privileges \u0027Lock Pages in Memory\u0027, \u0027Instant File Initialization\u0027, \u0027Logon as Batch\u0027 on one or more computers.\n\nRequires Local Admin rights on destination computer(s).",
"Description": "Gets the users with local privileges \u0027Lock Pages in Memory\u0027, \u0027Instant File Initialization\u0027, \u0027Logon as Batch\u0027, or \u0027Generate Security Audits\u0027 on one or more computers.\n\nRequires Local Admin rights on destination computer(s).",
"Tags": "Privilege",
"Synopsis": "Gets the users with local privileges on one or more computers.",
"Alias": "",
@@ -11,7 +11,7 @@
RootModule = 'dbatools.psm1'

# Version number of this module.
ModuleVersion = '1.0.64'
ModuleVersion = '1.0.65'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'

Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT </maml:para></maml:alert></maml:alertSet><command:examples><command:example><maml:title> -------------------------- EXAMPLE 1 -------------------------- </maml:title><maml:introduction><maml:para> PS C:\&gt; </maml:para></maml:introduction><dev:code> Get-DbaPowerPlan -ComputerName sql2017 </dev:code><dev:remarks><maml:para> Gets the Power Plan settings for sql2017 </maml:para></dev:remarks></command:example><command:example><maml:title> -------------------------- EXAMPLE 2 -------------------------- </maml:title><maml:introduction><maml:para> PS C:\&gt; </maml:para></maml:introduction><dev:code> Get-DbaPowerPlan -ComputerName sql2017 -Credential ad\admin </dev:code><dev:remarks><maml:para> Gets the Power Plan settings for sql2017 using an alternative credential </maml:para></dev:remarks></command:example></command:examples><maml:relatedLinks><maml:navigationLink><maml:linkText></maml:linkText><maml:uri>https://dbatools.io/Get-DbaPowerPlan</maml:uri></maml:navigationLink></maml:relatedLinks></command:command><command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"><command:details><command:name>Get-DbaPrivilege</command:name><command:noun>DbaPrivilege</command:noun><command:verb>Get</command:verb><maml:description><maml:para>Gets the users with local privileges on one or more computers.</maml:para></maml:description></command:details><maml:description><maml:para>Gets the users with local privileges 'Lock Pages in Memory', 'Instant File Initialization', 'Logon as Batch' on one or more computers.</maml:para><maml:para>Requires Local Admin rights on destination computer(s).</maml:para></maml:description><command:syntax><command:syntaxItem><maml:name>Get-DbaPrivilege</maml:name><command:parameter required="false" position="0" pipelineInput="True (ByValue)" aliases="" variableLength="true" globbing="false"><maml:name>ComputerName</maml:name><maml:description><maml:para>The target SQL Server instance or instances.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</command:parameterValue><dev:type><maml:name>Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="1" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>Credential</maml:name><maml:description><maml:para>Credential object used to connect to the computer as a different user.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue><dev:type><maml:name>Pscredential</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>EnableException</maml:name><maml:description><maml:para>By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
License: MIT https://opensource.org/licenses/MIT </maml:para></maml:alert></maml:alertSet><command:examples><command:example><maml:title> -------------------------- EXAMPLE 1 -------------------------- </maml:title><maml:introduction><maml:para> PS C:\&gt; </maml:para></maml:introduction><dev:code> Get-DbaPowerPlan -ComputerName sql2017 </dev:code><dev:remarks><maml:para> Gets the Power Plan settings for sql2017 </maml:para></dev:remarks></command:example><command:example><maml:title> -------------------------- EXAMPLE 2 -------------------------- </maml:title><maml:introduction><maml:para> PS C:\&gt; </maml:para></maml:introduction><dev:code> Get-DbaPowerPlan -ComputerName sql2017 -Credential ad\admin </dev:code><dev:remarks><maml:para> Gets the Power Plan settings for sql2017 using an alternative credential </maml:para></dev:remarks></command:example></command:examples><maml:relatedLinks><maml:navigationLink><maml:linkText></maml:linkText><maml:uri>https://dbatools.io/Get-DbaPowerPlan</maml:uri></maml:navigationLink></maml:relatedLinks></command:command><command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"><command:details><command:name>Get-DbaPrivilege</command:name><command:noun>DbaPrivilege</command:noun><command:verb>Get</command:verb><maml:description><maml:para>Gets the users with local privileges on one or more computers.</maml:para></maml:description></command:details><maml:description><maml:para>Gets the users with local privileges 'Lock Pages in Memory', 'Instant File Initialization', 'Logon as Batch', or 'Generate Security Audits' on one or more computers.</maml:para><maml:para>Requires Local Admin rights on destination computer(s).</maml:para></maml:description><command:syntax><command:syntaxItem><maml:name>Get-DbaPrivilege</maml:name><command:parameter required="false" position="0" pipelineInput="True (ByValue)" aliases="" variableLength="true" globbing="false"><maml:name>ComputerName</maml:name><maml:description><maml:para>The target SQL Server instance or instances.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</command:parameterValue><dev:type><maml:name>Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="1" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>Credential</maml:name><maml:description><maml:para>Credential object used to connect to the computer as a different user.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue><dev:type><maml:name>Pscredential</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>EnableException</maml:name><maml:description><maml:para>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.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Switch</command:parameterValue><dev:type><maml:name>Switch</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter></command:syntaxItem></command:syntax><command:parameters><command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>ComputerName</maml:name><maml:description><maml:para>The target SQL Server instance or instances.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</command:parameterValue><dev:type><maml:name>Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>Credential</maml:name><maml:description><maml:para>Credential object used to connect to the computer as a different user.</maml:para></maml:description><command:parameterValue required="false" variableLength="true">Pscredential</command:parameterValue><dev:type><maml:name>Pscredential</maml:name><maml:uri /></dev:type><dev:defaultValue></dev:defaultValue></command:parameter><command:parameter required="false" position="named" pipelineInput="False" aliases="" variableLength="true" globbing="false"><maml:name>EnableException</maml:name><maml:description><maml:para>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.

0 comments on commit e91fbce

Please sign in to comment.
You can’t perform that action at this time.