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
public static class ObjectExtensions | |
{ | |
public static string ToStringIfNotNull(this object o) | |
{ | |
return o == null ? null : o.ToString(); | |
} | |
} |
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
SELECT dbschemas.[name] as 'Schema', | |
dbtables.[name] as 'Table', | |
dbindexes.[name] as 'Index', | |
indexstats.avg_fragmentation_in_percent, | |
indexstats.page_count | |
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats | |
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] | |
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] | |
INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id] | |
AND indexstats.index_id = dbindexes.index_id |
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 EnergyLive | |
go | |
SELECT REQ.SESSION_ID, | |
RTRIM(convert(varchar(128),REQ.context_info)) AS BATCH_INFO, | |
SQL = SQL.text, | |
QUERYPLAN.query_plan AS EXEC_PLAN, | |
CPU_TIME, | |
TOTAL_ELAPSED_TIME, | |
READS, |
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
#requires -version 2.0 | |
<# | |
author: Johan Vosloo | |
date: 24/11/2011 | |
purpose: Retrieve event id’s from multiple machines and add to a CSV file. | |
#> | |
Try | |
{ | |
$servers=get-content c:\scripts\servers.txt | |
$date=(Get-Date).AddDays(-7) |
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
# | |
# Populate a list of servers where the only thing to change between servers is the number: | |
# | |
$servers = 1..10 | %{"ccioaxpi{0:00}edc" -f $_} ` | |
+ 1..2 | %{"ccioaxpf{0:00}edc" -f $_} | |
#This is the equivelant to: | |
#$servers = 'ccioaxpi01edc','ccioaxpi02edc','ccioaxpi03edc','ccioaxpi04edc','ccioaxpi05edc','ccioaxpi06edc','ccioaxpi07edc','ccioaxpi08edc','ccioaxpi09edc','ccioaxpi10edc','ccioaxpf01edc','ccioaxpf02edc' |
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
--::example batch file: | |
--pushd \\ukexchange\sysgrp\scripts\sql | |
--sqlcmd -S ccioaxpd05edc\axeam_train -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
--popd | |
--sql file: | |
-- - usage: | |
-- sqlcmd -S <server\instance> -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
use master | |
go |
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
[Enum]::GetValues([System.ConsoleColor]) | %{ Write-Host $_ -ForegroundColor $_ } |
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
::ensure 7zip directory is added to path environment variable (%programfiles%\7-zip) | |
7z x *.zip -o* |
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 [ax-support1-uatb] | |
go | |
DBCC SHRINKFILE (N'EnergyLive' , 0, TRUNCATEONLY) | |
--(get file name from db's properties) |
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
$adDummy = New-Object –TypeName PSObject –Prop @{ | |
emailSearched = $null; | |
notFound = $true; | |
sAmAccountName = $null; | |
fullname = $null; | |
firstname = $null; | |
lastname = $null; | |
cn = $null; | |
countryCode = $null; | |
country = $null; |
OlderNewer