Skip to content
Permalink
Browse files

1.0.80

  • Loading branch information
potatoqualitee committed Jan 6, 2020
1 parent 290ce3a commit 479a647a0370cb7f41ff71cccba3f7133e76300c
Showing with 157 additions and 10 deletions.
  1. +96 −2 allcommands.ps1
  2. +44 −2 bin/dbatools-index.json
  3. +3 −2 dbatools.psd1
  4. +2 −1 dbatools.psm1
  5. +12 −3 en-us/dbatools-help.xml
}
}


#.ExternalHelp dbatools-Help.xml
function Disable-DbaStartupProcedure {

}
}


#.ExternalHelp dbatools-Help.xml
function Enable-DbaStartupProcedure {

}
}

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

[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[DbaInstanceParameter[]]$SqlInstance = $env:COMPUTERNAME,
[PSCredential]$Credential,
[switch]$EnableException
)
process {
foreach ($instance in $SqlInstance) {
Write-Message -Level VeryVerbose -Message "Processing $instance" -Target $instance
$null = Test-ElevationRequirement -ComputerName $instance -Continue

try {
Write-Message -Level Verbose -Message "Resolving hostname."
$resolved = $null
$resolved = Resolve-DbaNetworkName -ComputerName $instance -Credential $Credential -EnableException
} catch {
$resolved = Resolve-DbaNetworkName -ComputerName $instance -Credential $Credential -Turbo
}

if ($null -eq $resolved) {
Stop-Function -Message "Can't resolve $instance" -Target $instance -Continue -Category InvalidArgument
}

try {
$sqlwmi = Invoke-ManagedComputerCommand -ComputerName $resolved.FullComputerName -ScriptBlock {
$wmi.Services
} -Credential $Credential -ErrorAction Stop | Where-Object DisplayName -eq "SQL Server ($($instance.InstanceName))"
} catch {
Stop-Function -Message "Failed to access $instance" -Target $instance -Continue -ErrorRecord $_
}

$regroot = ($sqlwmi.AdvancedProperties | Where-Object Name -eq REGROOT).Value
$vsname = ($sqlwmi.AdvancedProperties | Where-Object Name -eq VSNAME).Value
try {
$instancename = $sqlwmi.DisplayName.Replace('SQL Server (', '').Replace(')', '') # Don't clown, I don't know regex :(
} catch {
# Probably because the instance name has been aliased or does not exist or something
# here to avoid an empty catch
$null = 1
}
$serviceaccount = $sqlwmi.ServiceAccount

if ([System.String]::IsNullOrEmpty($regroot)) {
$regroot = $sqlwmi.AdvancedProperties | Where-Object {
$_ -match 'REGROOT'
}
$vsname = $sqlwmi.AdvancedProperties | Where-Object {
$_ -match 'VSNAME'
}

if (-not [System.String]::IsNullOrEmpty($regroot)) {
$regroot = ($regroot -Split 'Value\=')[1]
$vsname = ($vsname -Split 'Value\=')[1]
} else {
Stop-Function -Message "Can't find instance $vsname on $instance" -Continue -Category ObjectNotFound -Target $instance
}
}

if ([System.String]::IsNullOrEmpty($vsname)) {
$vsname = $instance
}

Write-Message -Level Verbose -Message "Regroot: $regroot" -Target $instance
Write-Message -Level Verbose -Message "ServiceAcct: $serviceaccount" -Target $instance
Write-Message -Level Verbose -Message "InstanceName: $instancename" -Target $instance
Write-Message -Level Verbose -Message "VSNAME: $vsname" -Target $instance

$scriptblock = {
$regpath = "Registry::HKEY_LOCAL_MACHINE\$($args[0])\MSSQLServer\SuperSocketNetLib"
$HideInstance = (Get-ItemProperty -Path $regpath -Name HideInstance).HideInstance

# [pscustomobject] doesn't always work, unsure why. so return hashtable then turn it into pscustomobject on client
@{
ComputerName = $env:COMPUTERNAME
InstanceName = $args[2]
SqlInstance = $args[1]
HideInstance = ($hideinstance -eq $true)
}
}

try {
$results = Invoke-Command2 -ComputerName $resolved.FullComputerName -Credential $Credential -ArgumentList $regroot, $vsname, $instancename -ScriptBlock $scriptblock -ErrorAction Stop -Raw
foreach ($result in $results) {
[pscustomobject]$result
}
} catch {
Stop-Function -Message "Failed to connect to $($resolved.FullComputerName) using PowerShell remoting" -ErrorRecord $_ -Target $instance -Continue
}
}
}
}

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

@@ -6440,7 +6440,7 @@
"Name": "Disable-DbaHideInstance",
"Description": "Disables the Hide Instance setting of the SQL Server network configuration.\n\nThis requires access to the Windows Server and not the SQL Server instance. The setting is found in SQL Server Configuration Manager under the properties of SQL Server Network Configuration \u003e Protocols for \"InstanceName\".",
"Tags": [
"HideInstance",
"Instance",
"Security"
],
"Synopsis": "Disables the Hide Instance setting of the SQL Server network configuration.",
@@ -6922,7 +6922,7 @@
"Name": "Enable-DbaHideInstance",
"Description": "Enables the Hide Instance setting of the SQL Server network configuration.\n\nThis setting requires access to the Windows Server and not the SQL Server instance. The setting is found in SQL Server Configuration Manager under the properties of SQL Server Network Configuration \u003e Protocols for \"InstanceName\".",
"Tags": [
"HideInstance",
"Instance",
"Security"
],
"Synopsis": "Enables the Hide Instance setting of the SQL Server network configuration.",
],
"Syntax": "Get-DbaHelpIndex [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [[-ObjectName] \u003cString\u003e] [-IncludeStats] [-IncludeDataTypes] [-Raw] [-IncludeFragmentation] [-EnableException] [\u003cCommonParameters\u003e]"
},
{
"Name": "Get-DbaHideInstance",
"Description": "Gets Hide Instance settings for a SQL Server instance. Note that this requires access to the Windows Server - not the SQL instance itself.\n\nThis setting is found in Configuration Manager.",
"Tags": [
"Instance",
"Security"
],
"Synopsis": "Gets Hide Instance settings for a SQL Server instance",
"Alias": "",
"Author": "Tracy Boggiano @TracyBoggiano, databaseuperhero.com",
"CommandName": "Get-DbaHideInstance",
"Availability": "Windows only",
"Links": "https://dbatools.io/Get-DbaHideInstance",
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaHideInstance\nGets Hide Instance properties on the default (MSSQLSERVER) instance on localhost - requires (and checks for) RunAs admin.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaHideInstance -SqlInstance sql01\\SQL2008R2SP2\nGets Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both login and view the registry.",
"Params": [
[
"SqlInstance",
"The target SQL Server instance or instances. Defaults to localhost.",
"",
false,
"true (ByValue)",
"$env:COMPUTERNAME"
],
[
"Credential",
"Allows you to login to the computer (not sql instance) using alternative Windows credentials",
"",
false,
"false",
""
],
[
"EnableException",
"By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.",
"",
false,
"false",
"False"
]
],
"Syntax": "Get-DbaHideInstance [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]"
},
{
"Name": "Get-DbaInstanceAudit",
"Description": "The Get-DbaInstanceAudit command gets SQL Security Audit information for each instance(s) of SQL Server.",
@@ -11,7 +11,7 @@
RootModule = 'dbatools.psm1'

# Version number of this module.
ModuleVersion = '1.0.79'
ModuleVersion = '1.0.80'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'
@@ -598,8 +598,9 @@
'Enable-DbaForceNetworkEncryption',
'Disable-DbaForceNetworkEncryption',
'Get-DbaForceNetworkEncryption',
'Disable-DbaHideInstance',
'Get-DbaHideInstance',
'Enable-DbaHideInstance',
'Disable-DbaHideInstance',
'New-DbaComputerCertificateSigningRequest',
'Remove-DbaComputerCertificate',
'New-DbaComputerCertificate',
@@ -870,8 +870,9 @@ $script:windowsonly = @(
'Enable-DbaForceNetworkEncryption',
'Disable-DbaForceNetworkEncryption',
'Get-DbaForceNetworkEncryption',
'Disable-DbaHideInstance',
'Get-DbaHideInstance',
'Enable-DbaHideInstance',
'Disable-DbaHideInstance',
'New-DbaComputerCertificateSigningRequest',
'Remove-DbaComputerCertificate',
'New-DbaComputerCertificate',

0 comments on commit 479a647

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