<commit_before>Function Reset-SqlAdmin
{
<# 
.SYNOPSIS 
This function will allow administrators to regain access to SQL Servers in the event that passwords or access was lost.

Supports SQL Server 2005 and above. Windows administrator access is required.

.DESCRIPTION
This function allows administrators to regain access to local or remote SQL Servers by either resetting the sa password, adding sysadmin role to existing login,
or adding a new login (SQL or Windows) and granting it sysadmin privileges.

This is accomplished by stopping the SQL services or SQL Clustered Resource Group, then restarting SQL via the command-line
using the /mReset-SqlAdmin paramter which starts the server in Single-User mode, and only allows this script to connect.

Once the service is restarted, the following tasks are performed:
- Login is added if it doesn't exist
- If login is a Windows User, an attempt is made to ensure it exists
- If login is a SQL Login, password policy will be set to OFF when creating the login, and SQL Server authentication will be set to Mixed Mode.
- Login will be enabled and unlocked
- Login will be added to sysadmin role

If failures occur at any point, a best attempt is made to restart the SQL Server.

In order to make this script as portable as possible, System.Data.SqlClient and Get-WmiObject are used (as opposed to requiring the Failover Cluster Admin tools or SMO).
If using this function against a remote SQL Server, ensure WinRM is configured and accessible. If this is not possible, run the script locally.

Tested on Windows XP, 7, 8.1, Server 2012 and Windows Server Technical Preview 2.
Tested on SQL Server 2005 SP4 through 2016 CTP2.


.PARAMETER SqlServer
The SQL Server instance. SQL Server must be 2005 and above, and can be a clustered or stand-alone instance.

.PARAMETER Login
By default, the Login parameter is "sa" but any other SQL or Windows account can be specified. If a login does not
currently exist, it will be added.

When adding a Windows login to remote servers, ensure the SQL Server can add the login (ie, don't add WORKSTATION\Admin to remoteserver\instance. Domain users and 
Groups are valid input.

.PARAMETER Force
By default, a confirmation is presented to ensure the person executing the script knows that a service restart will occur. Force basically performs a -Confirm:$false. This will restart the SQL Service without prompting.
<commit_msg>Added Parameters Help for Whatif and Confirm to pass Pester Tests<commit_after>Function Reset-SqlAdmin
{
<# 
.SYNOPSIS 
This function will allow administrators to regain access to SQL Servers in the event that passwords or access was lost.

Supports SQL Server 2005 and above. Windows administrator access is required.

.DESCRIPTION
This function allows administrators to regain access to local or remote SQL Servers by either resetting the sa password, adding sysadmin role to existing login,
or adding a new login (SQL or Windows) and granting it sysadmin privileges.

This is accomplished by stopping the SQL services or SQL Clustered Resource Group, then restarting SQL via the command-line
using the /mReset-SqlAdmin paramter which starts the server in Single-User mode, and only allows this script to connect.

Once the service is restarted, the following tasks are performed:
- Login is added if it doesn't exist
- If login is a Windows User, an attempt is made to ensure it exists
- If login is a SQL Login, password policy will be set to OFF when creating the login, and SQL Server authentication will be set to Mixed Mode.
- Login will be enabled and unlocked
- Login will be added to sysadmin role

If failures occur at any point, a best attempt is made to restart the SQL Server.

In order to make this script as portable as possible, System.Data.SqlClient and Get-WmiObject are used (as opposed to requiring the Failover Cluster Admin tools or SMO).
If using this function against a remote SQL Server, ensure WinRM is configured and accessible. If this is not possible, run the script locally.

Tested on Windows XP, 7, 8.1, Server 2012 and Windows Server Technical Preview 2.
Tested on SQL Server 2005 SP4 through 2016 CTP2.


.PARAMETER SqlServer
The SQL Server instance. SQL Server must be 2005 and above, and can be a clustered or stand-alone instance.

.PARAMETER Login
By default, the Login parameter is "sa" but any other SQL or Windows account can be specified. If a login does not
currently exist, it will be added.

When adding a Windows login to remote servers, ensure the SQL Server can add the login (ie, don't add WORKSTATION\Admin to remoteserver\instance. Domain users and 
Groups are valid input.

.PARAMETER Force
By default, a confirmation is presented to ensure the person executing the script knows that a service restart will occur. Force basically performs a -Confirm:$false. This will restart the SQL Service without prompting.

.PARAMETER WhatIf 
Shows what would happen if the command were to run. No actions are actually performed. 

.PARAMETER Confirm 
Prompts you for confirmation before executing any changing operations within the command. 

{'fraction_non_alphanumeric': 0.03354256571204394, 'fraction_numerical': 0.010200078462142017, 'mean_word_length': 4.339267015706806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '941802', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1207, 'n_words': 811}