Skip to content

Commit

Permalink
0.9.771
Browse files Browse the repository at this point in the history
adding current commands and prepping for future command
  • Loading branch information
potatoqualitee committed Feb 20, 2019
1 parent 8261ba8 commit 1d9fb03
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 2 deletions.
107 changes: 106 additions & 1 deletion allcommands.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69780,6 +69780,107 @@ function New-DbaDbCertificate {
}
}
}
#ValidationTags#Messaging,FlowControl,Pipeline,CodeStyle#
function New-DbaDbMailProfile {
<#
.SYNOPSIS
Creates a new database mail profile

.DESCRIPTION
Creates a new database mail profile, and optionally associates it to a database mail account

.PARAMETER SqlInstance
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.

.PARAMETER SqlCredential
Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)

.PARAMETER Name
The Name of the profile to be created.

.PARAMETER Description
Sets the description of the purpose of the mail profile.

.PARAMETER MailAccountName
Associates a db mail account to link to this db mail profile.

.PARAMETER MailAccountPriority
Sets the priority of the linked db mail account when linking to this db mail profile.

.PARAMETER WhatIf
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

.PARAMETER Confirm
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

.PARAMETER EnableException
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.

.NOTES
Tags: DbMail
Author: Ian Lanham (@ilanham)

Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT

.LINK
https://dbatools.io/New-DbaDbMailProfile

.EXAMPLE
PS C:\> $profile = New-DbaDbMailProfile -SqlInstance sql2017 -Name 'The DBA Team'

Creates a new db mail profile

#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")]
param (
[parameter(Mandatory, ValueFromPipeline)]
[Alias("ServerInstance", "SqlServer")]
[DbaInstanceParameter[]]$SqlInstance,
[PSCredential]$SqlCredential,
[parameter(Mandatory)]
[string]$Name,
[string]$Description,
[string]$MailAccountName,
[int]$MailAccountPriority,
[switch]$EnableException
)
process {
foreach ($instance in $SqlInstance) {
try {
$server = Connect-SqlInstance -SqlInstance $instance -SqlCredential $SqlCredential -MinimumVersion 11
} catch {
Stop-Function -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $instance -Continue
}

if ($Pscmdlet.ShouldProcess($instance, "Creating new db mail profile called $Name")) {
try {
$profile = New-Object Microsoft.SqlServer.Management.SMO.Mail.MailProfile $server.Mail, $Name
if (Test-Bound -ParameterName 'Description') {
$profile.Description = $Description
}
$profile.Create()
if (Test-Bound -ParameterName 'MailAccountName') {
if (!$MailAccountPriority) {
$MailAccountPriority = 1
}
$profile.AddAccount($MailAccountName, $MailAccountPriority) # sequenceNumber correlates to "Priority" when associating a db mail Account to a db mail Profile
}
Add-Member -Force -InputObject $profile -MemberType NoteProperty -Name ComputerName -value $server.ComputerName
Add-Member -Force -InputObject $profile -MemberType NoteProperty -Name InstanceName -value $server.ServiceName
Add-Member -Force -InputObject $profile -MemberType NoteProperty -Name SqlInstance -value $server.DomainInstanceName

$profile | Select-DefaultView -Property ComputerName, InstanceName, SqlInstance, Id, Name, Description, IsBusyProfile
} catch {
Stop-Function -Message "Failure" -ErrorRecord $_ -Continue
}
}
}
}
}
function New-DbaDbMaskingConfig {
<#
.SYNOPSIS
Expand Down Expand Up @@ -71619,7 +71720,11 @@ function New-DbaLogin {
try {
if ($loginType -eq 'AsymmetricKey') { $sql = "CREATE LOGIN [$loginName] FROM ASYMMETRIC KEY [$currentAsymmetricKey]" }
elseif ($loginType -eq 'Certificate') { $sql = "CREATE LOGIN [$loginName] FROM CERTIFICATE [$currentCertificate]" }
elseif ($loginType -eq "SqlLogin") { $sql = "CREATE LOGIN [$loginName] WITH PASSWORD = $currentHashedPassword HASHED" + $withParams }
elseif ($loginType -eq 'SqlLogin' -and $server.DatabaseEngineType -eq 'SqlAzureDatabase') {
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword) # Azure SQL doesn't support HASHED so we have to dump out the plain text password :(
$unsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$sql = "CREATE LOGIN [$loginName] WITH PASSWORD = '$unsecurePassword'"
} elseif ($loginType -eq 'SqlLogin' ) { $sql = "CREATE LOGIN [$loginName] WITH PASSWORD = $currentHashedPassword HASHED" + $withParams }
else { $sql = "CREATE LOGIN [$loginName] FROM WINDOWS" + $withParams }

$null = $server.Query($sql)
Expand Down
164 changes: 164 additions & 0 deletions bin/dbatools-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -22015,6 +22015,83 @@
],
"Syntax": "Invoke-DbaAdvancedRestore [-BackupHistory] \u003cObject[]\u003e [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-OutputScriptOnly] [-VerifyOnly] [[-RestoreTime] \u003cDateTime\u003e] [[-StandbyDirectory] \u003cString\u003e] [-NoRecovery] [[-MaxTransferSize] \u003cInt32\u003e] [[-BlockSize] \u003cInt32\u003e] [[-BufferCount] \u003cInt32\u003e] [-Continue] [[-AzureCredential] \u003cString\u003e] [-WithReplace] [-KeepCDC] [[-PageRestore] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]"
},
{
"Name": "Invoke-DbaAdvancedUpdate",
"Description": "Invokes an update process for a single computer and restarts it if needed",
"Synopsis": "Designed for internal use, implements parallel execution for Update-DbaInstance.",
"Alias": "",
"CommandName": "Invoke-DbaAdvancedUpdate",
"Availability": "Windows only",
"Links": null,
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaAdvancedUpdate -ComputerName SQL1 -Action $actions -RestartNeeded $true\nInvokes update actions on SQL1 after restarting it.",
"Params": [
[
"ComputerName",
"Target computer with SQL instance or instances.",
"",
false,
"false",
""
],
[
"Action",
"An object containing the action plan",
"",
false,
"false",
""
],
[
"Restart",
"Restart computer automatically after a successful installation of a patch and wait until it comes back online.\r\nUsing this parameter is the only way to chain-install more than 1 patch on a computer, since every single patch will require a restart of said computer.",
"",
false,
"false",
"False"
],
[
"Authentication",
"Chooses an authentication protocol for remote connections.\r\nIf the protocol fails to establish a connection\nDefaults:\r\n* CredSSP when -Credential is specified - due to the fact that repository Path is usually a network share and credentials need to be passed to the remote host\r\n to avoid the double-hop issue.\r\n* Default when -Credential is not specified. Will likely fail if a network path is specified.",
"",
false,
"false",
"Credssp"
],
[
"Credential",
"Windows Credential with permission to log on to the remote server.\r\nMust be specified for any remote connection if update Repository is located on a network folder.",
"",
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"
],
[
"WhatIf",
"Shows what would happen if the command were to run. No actions are actually performed.",
"wi",
false,
"false",
""
],
[
"Confirm",
"Prompts you for confirmation before executing any changing operations within the command.",
"cf",
false,
"false",
""
]
],
"Syntax": "Invoke-DbaAdvancedUpdate [[-ComputerName] \u003cString\u003e] [[-Action] \u003cObject[]\u003e] [[-Restart] \u003cBoolean\u003e] [[-Authentication] \u003cString\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]"
},
{
"Name": "Invoke-DbaAgFailover",
"Description": "Failover an availability group.",
Expand Down Expand Up @@ -28014,6 +28091,93 @@
],
"Syntax": "New-DbaDbCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-Database] \u003cString[]\u003e] [[-Subject] \u003cString[]\u003e] [[-StartDate] \u003cDateTime\u003e] [[-ExpirationDate] \u003cDateTime\u003e] [-ActiveForServiceBrokerDialog] [[-SecurePassword] \u003cSecureString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]"
},
{
"Name": "New-DbaDbMailProfile",
"Description": "Creates a new database mail profile, and optionally associates it to a database mail account",
"Tags": "DbMail",
"Synopsis": "Creates a new database mail profile",
"Alias": "",
"Author": "Ian Lanham (@ilanham)",
"CommandName": "New-DbaDbMailProfile",
"Availability": "Windows, Linux, macOS",
"Links": "https://dbatools.io/New-DbaDbMailProfile",
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$profile = New-DbaDbMailProfile -SqlInstance sql2017 -Name \u0027The DBA Team\u0027\nCreates a new db mail profile",
"Params": [
[
"SqlInstance",
"The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.",
"ServerInstance,SqlServer",
true,
"true (ByValue)",
""
],
[
"SqlCredential",
"Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)",
"",
false,
"false",
""
],
[
"Name",
"The Name of the profile to be created.",
"",
true,
"false",
""
],
[
"Description",
"Sets the description of the purpose of the mail profile.",
"",
false,
"false",
""
],
[
"MailAccountName",
"Associates a db mail account to link to this db mail profile.",
"",
false,
"false",
""
],
[
"MailAccountPriority",
"Sets the priority of the linked db mail account when linking to this db mail profile.",
"",
false,
"false",
"0"
],
[
"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"
],
[
"WhatIf",
"If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.",
"wi",
false,
"false",
""
],
[
"Confirm",
"If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.",
"cf",
false,
"false",
""
]
],
"Syntax": "New-DbaDbMailProfile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString\u003e [[-Description] \u003cString\u003e] [[-MailAccountName] \u003cString\u003e] [[-MailAccountPriority] \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]"
},
{
"Name": "New-DbaDbMaskingConfig",
"Description": "Generates a new data masking configuration file. This file is important to apply any data masking to the data in a database.\n\nNote that the following column and data types are not currently supported:\nIdentity\nForeignKey\nComputed\nHierarchyid\nGeography\nGeometry\nXml\n\nRead more here:\nhttps://sachabarbs.wordpress.com/2018/06/11/bogus-simple-fake-data-tool/\nhttps://github.com/bchavez/Bogus",
Expand Down
5 changes: 4 additions & 1 deletion dbatools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'dbatools.psm1'

# Version number of this module.
ModuleVersion = '0.9.770'
ModuleVersion = '0.9.771'

# ID used to uniquely identify this module
GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'
Expand Down Expand Up @@ -361,6 +361,9 @@
'Get-DbaDbMailProfile',
'Get-DbaDbMailConfig',
'Get-DbaDbMailServer',
'New-DbaDbMailServer',
'New-DbaDbMailAccount',
'New-DbaDbMailProfile',
'Get-DbaResourceGovernor',
'Get-DbaRgResourcePool',
'Get-DbaRgWorkloadGroup',
Expand Down
3 changes: 3 additions & 0 deletions dbatools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,9 @@ $script:xplat = @(
'Get-DbaDbMailProfile',
'Get-DbaDbMailConfig',
'Get-DbaDbMailServer',
'New-DbaDbMailServer',
'New-DbaDbMailAccount',
'New-DbaDbMailProfile',
'Get-DbaResourceGovernor',
'Get-DbaRgResourcePool',
'Get-DbaRgWorkloadGroup',
Expand Down

0 comments on commit 1d9fb03

Please sign in to comment.