Converted into a module: https://github.com/tcartwright/AddNoteProperty
PS Gallery link: https://www.powershellgallery.com/packages/AddNoteProperty/
SELECT s.name, | |
LEFT(fn2.target_path, Len(fn2.target_path) - Charindex('\', Reverse(fn2.target_path))) AS target_dir, | |
fn2.target_path | |
FROM sys.dm_xe_session_targets AS t | |
JOIN sys.dm_xe_sessions AS s | |
ON s.address = t.event_session_address | |
CROSS APPLY ( | |
SELECT CAST(t.target_data AS XML) AS [target_data_xml] | |
) fn | |
CROSS APPLY ( |
# Original Source: https://www.timschaeps.be/post/using-the-tf-command-to-clean-up-old-tfvc-workspaces/ | |
$moduleName = "EnterDeveloperPowerShell" | |
$module = Get-InstalledModule $moduleName -ErrorAction SilentlyContinue | |
if (-not $module) { | |
Write-Host "Installing module: $moduleName" | |
Install-Module -Name $moduleName -Force | |
} | |
Import-Module $moduleName | |
Enter-VisualStudioDeveloperShell |
# only way to safely get an optional property off an object when strict mode is on | |
function GetOptionalPropertyValue($obj, [string]$propertyName, [object]$defaultValue, [switch]$isCollection) { | |
$prop = $obj.PsObject.Properties[$propertyName] | |
if ($prop) { | |
if ($isCollection.IsPresent) { | |
return ,$prop.Value | |
} else { | |
return $prop.Value | |
} | |
} elseif ($isCollection.IsPresent) { |
<# | |
Original credits: https://newbedev.com/powershell-assembly-binding-redirect-not-found-in-application-configuration-file | |
Purpose: To provide an assembly resolve event that does not crash PowerShell with a stackoverflow exception, and works. | |
Tim Cartwright: rewrote to be less complicated, and to resolve 100% of the time IF the assembly has already been loaded with a diff version. | |
If need be, before the resolver is called, either use Add-Type, or [System.Reflection.Assembly]::LoadWithPartialName("") | |
to load the assembly needed before hand if it is not already in your cache. | |
TO VERIFY IF THE NEEDED ASSEMBLY IS IN YOUR CACHE: |
To reset last commit: | |
git commit --amend --reset-author --no-edit | |
FOR MANY: | |
Found this answer here: https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi/9491696#9491696 | |
START: |
/* | |
- BEWARE: Login triggers can lock down your system if not coded right (Knew that, just learned it the hard way) | |
- This login running the trigger should be a certificate account, and not have a password. | |
- Can also optionally disable the login. Does not seem to affect trigger execution | |
- Don't leave the trigger enabled. | |
- Don't test modifications on a server that other users are connecting to. | |
*/ | |
USE master |
Converted into a module: https://github.com/tcartwright/AddNoteProperty
PS Gallery link: https://www.powershellgallery.com/packages/AddNoteProperty/
$scriptRoot = [System.IO.Directory]::GetParent($MyInvocation.MyCommand.Definition) | |
. ([System.IO.Path]::Combine($scriptRoot, "Install-Package.ps1")) | |
$jsonAssemblyFile = InstallPackage -packageName Newtonsoft.Json | |
$jsonSchemaAssemblyFile = InstallPackage -packageName Newtonsoft.Json.Schema | |
$validatorSource = @" | |
using Newtonsoft.Json.Linq; |
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator); | |
function InstallPackage($packageName, $dllName, [switch]$force) { | |
if (!$dllName) { | |
$dllName = "$($packageName).dll" | |
} | |
$package = Get-Package $packageName -ErrorAction SilentlyContinue | |
if (-not $package -or $force.IsPresent) { |
DECLARE @sd DATETIME2(7) = '2021-08-25 12:16:16.6969221', | |
@ed DATETIME2(7) = '2021-08-26 15:40:52.4579221' | |
DECLARE @diff DECIMAL(19, 7) = DATEDIFF(MILLISECOND, @sd, @ed) | |
SELECT CONCAT ( | |
CAST(@diff / (1000 * 60 * 60 * 24) AS INT), --days | |
'.', |