This file contains 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
DECLARE @XmlStoredAsNvarchar nvarchar(4000) = ' | |
<EventContext> | |
<eventType>Save Test Data</eventType> | |
<discipline>Operations</discipline> | |
<documentNumber>1.2.3.4</documentNumber> | |
<documentVersion>1.0</documentVersion> | |
<sectionNumber>1.2.1.1</sectionNumber> | |
<sectionName>Test section: XML Test</sectionName> | |
<tableIdentifier>1</tableIdentifier> | |
<objectType>Object</objectType> |
This file contains 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 Update-JamesStatus { | |
[CmdletBinding()] | |
param( | |
[Parameter(Position = 1)] | |
[ValidateNotNullOrEmpty()] | |
[String] | |
$SlackTitle = 'James is locked out again...', | |
[Parameter(Position = 2)] | |
[ValidateNotNullOrEmpty()] |
This file contains 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
while ((Get-Date) -lt (Get-Date '2019-01-08 17:00:00')) { | |
$JamesLockedAccount = Search-ADAccount -LockedOut | Where-Object Name -eq 'James ReportWriter' | |
if ($JamesLockedAccount) { | |
New-BurntToastNotification -Text 'James is locked out again.' | |
# Since this is a script, I'll manually clean up after myself. | |
Remove-Variable -Name JamesLockedAccount | |
} | |
This file contains 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
Search-ADAccount -LockedOut | | |
Where-Object Name -eq 'James ReportWriter' | | |
Unlock-ADAccount |
This file contains 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
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' | |
. "$here\$sut" |
This file contains 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
$String = 'SQL Server' | |
for ($i = 0; $i -lt $String.Length; $i++ ) { | |
[PSCustomObject]@{ | |
'This Char' = $string[$i] | |
'Prev Char' = $string[$i -1] | |
'Next Char' = $string[($i +1) % $String.Length] | |
} | |
} |
This file contains 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
$String = 'SQL Server' | |
0..($String.Length - 1) | ForEach-Object -Process { | |
$String.Substring($_, 1) | |
} |
This file contains 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
WITH Algorithms ([algorithm]) AS ( | |
SELECT [algorithm] | |
FROM (VALUES ('MD2'), ('MD4'), ('MD5'), ('SHA'), ('SHA1'), ('SHA2_256'), ('SHA2_512')) AS t([algorithm]) | |
) | |
SELECT [algorithm], | |
t.hashed_varchar, | |
u.hashed_nvarchar, | |
checked_varchar = CHECKSUM('a'), | |
checked_nvarchar = CHECKSUM(N'a') | |
FROM Algorithms |
This file contains 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
USE tempdb; | |
GO | |
DROP TABLE IF EXISTS dbo.NonUnicode; | |
DROP TABLE IF EXISTS dbo.Unicode; | |
CREATE TABLE dbo.NonUnicode (NU varchar(1) NOT NULL DEFAULT 'a') | |
CREATE TABLE dbo.Unicode (U nvarchar(1) NOT NULL DEFAULT N'a'); | |
INSERT INTO dbo.NonUnicode (NU) DEFAULT VALUES; | |
INSERT INTO dbo.Unicode (U) DEFAULT VALUES; |
This file contains 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 Get-ParameterAlias { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0)] | |
[Alias('Function')] | |
[String[]] | |
$Command | |
) | |
begin { |