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
SELECT * FROM sys.dm_exec_query_resource_semaphores WHERE pool_id = 1 | |
SELECT S1.session_id, S1.[host_name], S1.[program_name], S1.login_name | |
, R1.command, R1.status, R1.wait_type, R1.wait_time, R1.last_wait_type, R1.wait_resource | |
, M1.* | |
FROM sys.dm_exec_sessions AS S1 | |
JOIN sys.dm_exec_requests AS R1 | |
ON S1.session_id = R1.session_id | |
LEFT | |
JOIN sys.dm_exec_query_memory_grants AS M1 |
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
-- | |
-- Audit applications that connects to a specified database using | |
-- Windows Integrated Authentication storing the applications names | |
-- and the number of connections. | |
-- | |
-- Requires SQL Server version >= 2012 | |
-- Activate SQLCMD mode before running | |
-- | |
:setvar DatabaseName TestDatabase |
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
-- | |
-- Profile connections using Event Notification and AUDIT_LOGIN events | |
-- to create a summary of number of logins by database, application, login and hostname | |
-- additionally tracking domain name and user | |
-- | |
USE DBPerfmon | |
GO | |
-- Prerequisites | |
ALTER DATABASE DBPerfmon SET ENABLE_BROKER; |
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
# Normalizes perfmon logs names given a set of directories | |
# following the pattern COMPUTERNAME_YYYYMMDD-NNNNNN | |
# by moving log files to the root dir and assigning a unique name | |
$PALDir = "D:\Temp\PAL" | |
Get-ChildItem $PALDir -Directory | | |
? { $_.Name -match "(?<ComputerName>\w*)_(?<ISODate>\d{4}\d{2}\d{2})-(?<Sequence>\d{6})" } | | |
% { | |
$file = Get-ChildItem $_.FullName; | |
$file.MoveTo($PALDir + "\" + $Matches["ComputerName"] + "_PAL_" + $Matches["ISODate"] + "_" + $Matches["Sequence"]+".blg"); |
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
Param($ServerName="GSRVBI1") | |
cls | |
$loadInfo = [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") | |
$server = New-Object Microsoft.AnalysisServices.Server | |
$server.connect($ServerName) | |
if ($server.name -eq $null) { | |
Write-Output ("Server [{0}] not found" -f $ServerName) | |
break | |
} |
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
SELECT DSS.servicename, | |
DSS.startup_type_desc, | |
DSS.status_desc, | |
DSS.last_startup_time, | |
DSS.service_account, | |
DSS.is_clustered, | |
DSS.cluster_nodename, | |
DSS.filename, | |
DSS.startup_type, | |
DSS.status, |
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
# | |
# This script checks that all pictures from a Windows Phone Lumia 1020 | |
# have been uploaded to OneDrive. | |
# | |
# It takes a local backup of the phone's Camera Roll directory copied directly | |
# from the phone and checks that all pictures are present in Onedrive's local | |
# copy of the Camera Roll directory. | |
# | |
# Note: the scripts assumes hires copies are automatically uploaded and | |
# removes pictures that are already present without the __highres suffix |
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
# | |
# Exiftool example to process multiple commands without paying the initialization time | |
# for each call writing to an argument file | |
# | |
cls; | |
$Inputdir = "C:\Photos\Personal\[2007]\[2007-00-00] Test & Test" | |
# initializes argument file | |
if (Test-Path c:\temp\tmp.args) { del c:\temp\tmp.args; }; | |
$null | Out-File c:\temp\tmp.args -Append -Encoding Ascii; |
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
SELECT DB_NAME(F.database_id) AS database_name, F.[name] as logical_filename, type_desc | |
, CAST(CAST(size as bigint) * 8192 / 1024. /1024. AS decimal(15,2)) AS size_mb | |
, is_percent_growth | |
, CASE is_percent_growth WHEN 0 THEN CAST(CAST(growth as bigint) * 8192 / 1024. /1024. AS decimal(15,2)) END AS growth_mb | |
, CASE is_percent_growth WHEN 1 THEN growth END AS growth_percent | |
, 'ALTER DATABASE [' + DB_NAME(F.database_id) + '] MODIFY FILE (NAME = ''' + F.[name] + '''' | |
+ CASE | |
WHEN type_desc = 'LOG' AND (CAST(size as bigint) * 8192) < (256*1024*1024) THEN ', SIZE = 64MB' | |
ELSE '' | |
END |
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
# | |
# Removes incorrect data from *.tcx files exported from the Polar Flow | |
# web site so they can be uploaded to the Garmin web site. | |
# More info: https://forums.garmin.com/showthread.php?165708-Polar-Flow-TCX-export-to-Garmin-Connect | |
# | |
$SourceDir = "C:\Users\Gianluca\OneDrive\Documents\Health\PolarFlow"; | |
$DestinationDir = "C:\Users\Gianluca\OneDrive\Documents\Health\ExportGarmin"; | |
Get-ChildItem $SourceDir -Include "*.tcx" -Recurse | | |
Where-Object { !(Test-Path (Join-Path $DestinationDir $_.Name)) } | |