This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import-module PSFramework | |
| If ([Environment]::Is64BitProcess) { | |
| $Message = "Running in a 64-bit PowerShell process, PowerShell {0}" -f @($PSVersionTable.PSVersion) | |
| $Message += ' It must run in a 32-bit process because it accesses a FoxPro database.' | |
| } | |
| else { | |
| $Message = 'Running in a 32-bit PowerShell process, PowerShell {0}' -f @($PSVersionTable.PSVersion) | |
| Write-PSFMessage -Level 'Verbose' -Message $Message | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Set-DbatoolsConfig -FullName sql.connection.trustcert -Value $true -Register |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @REM This will work from a .BAT or .CMD file, or from the CMD console. | |
| @REM It's too slow to be used for regular work but it's OK for debugging and troubleshooting. | |
| @REM It's mainly about enforcing a standard format to make it easier to parse the log file later. | |
| PowerShell -noprofile -nologo -command "$LogLevel = 'INFO'; $Message = 'Something notable happened';$OutputTemplate = '{0},{1},{2},{3}'; Add-Content -path .\Simple.log.txt -value ($OutputTemplate -f @((Get-Date).ToString('s'), $LogLevel, $ENV:UserName, $Message) ) " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$help": "https://aka.ms/terminal-documentation", | |
| "$schema": "https://aka.ms/terminal-profiles-schema", | |
| "actions": | |
| [ | |
| { | |
| "command": | |
| { | |
| "action": "copy", | |
| "singleLine": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function foo { | |
| [cmdletbinding()] | |
| param ( | |
| [Parameter(Mandatory = $true, | |
| ValueFromPipeline=$True, | |
| ValueFromPipelineByPropertyName=$True | |
| )] | |
| [string[]] $DestinationDatabase, | |
| $TestName | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create the SqlConnection object | |
| $s = New-Object System.Data.SqlClient.SqlConnection | |
| # Build an appropriate string, using the string builder from DbaTools | |
| $s.ConnectionString = New-DbaSqlConnectionStringBuilder -DataSource hal9000 -ApplicationName 'MyAppName' -InitialCatalog 'tempDB' -WorkstationId dstraitv7 -ColumnEncryptionSetting Disabled -IntegratedSecurity $true | |
| # Run a query to show that we are not yet in a transaction. | |
| # Since this is the first use of $s, this will open the connection if it isn't open already | |
| Invoke-SqlCmd2 -Connection $s -Query "select 0 'QueryNumber', @@TRANCOUNT as CountOfTranBeforeBegin" | |
| # Start a transaction | |
| Invoke-SqlCmd2 -Connection $s -Query "begin tran" | |
| # Queries 1 and 2 are just contrived nonsense |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| .SYNOPSIS | |
| Set up backups to test Restore-DbaDatabase -RestoreTime feature when restoring a DB in Simple mode. | |
| .NOTES | |
| The file names here are 'Ola Hallengren'-like, but not exactly. The work for the purpose sof the test. | |
| The file names don't match 100% to the write times either. The script had a few executions before I | |
| had what I wanted and didn't bother changing the file names to match the times they were written. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| .PURPOSE | |
| A demo of how calling a procedure can silently truncate data. | |
| .AUTHOR | |
| [email protected] | |
| .HISTORY | |
| 2017/07/13 @dstrait Initial version | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| A simple example of how to use parameter sets | |
| .DESCRIPTION | |
| A simple example of how to use parameter sets. | |
| Imagine that you have a function that could take a file ID or a file name. | |
| If provided a file name, then look up the file ID and proceed as normal with that value. |
NewerOlder