Skip to content

Instantly share code, notes, and snippets.

@matejskubic
matejskubic / DirectAccess-diag.ps1
Created April 28, 2013 18:30
DirectAccess diagnostics
netsh dnsclient show state
netsh name show effective
netsh name show policy
netsh interface httpstunnel show interfaces
Get-DAConnectionStatus
@matejskubic
matejskubic / sql-restore-pregress.sql
Created May 17, 2013 12:41
SQL Server backup/restore progress
SELECT r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete)
AS [Percent Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA Completion Time],
CONVERT(NUMERIC(10,2),r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA Hours],
CONVERT(VARCHAR(1000),(SELECT SUBSTRING(text,r.statement_start_offset/2,
CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END)
FROM sys.dm_exec_sql_text(sql_handle)))
FROM sys.dm_exec_requests r WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')
@matejskubic
matejskubic / SearchAxModelDbForSourceText.sql
Created May 27, 2013 12:26
Search AX model database for source code
SELECT TOP 10
root.Name RootElemnetName
, me.Name ElementName
, et.ElementTypeName
, CAST([SourceText] AS nvarchar(MAX)) SourceText
, me.RootHandle
, me.ElementHandle
FROM [dbo].[Sources] s
JOIN ModelElement me ON s.SourceHandle=me.ElementHandle
JOIN ModelElement root on root.ElementHandle=me.RootHandle
@matejskubic
matejskubic / change-namespace.xslt
Created June 26, 2013 07:54
change xml node namespace with xslt/xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:old="http://something/old/"
xmlns:new="http://something/new/">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
@matejskubic
matejskubic / gist:10268126
Created April 9, 2014 13:06
Setup your IIS for SSL Perfect Forward Secrecy and TLS 1.2
### http://www.hass.de/content/setup-your-iis-ssl-perfect-forward-secrecy-and-tls-12
# Add and Enable SSL 3.0 for client and server SCHANNEL communications
md 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0' -Force
md 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server' -Force
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server' -name 'Enabled' -value '0xffffffff' -PropertyType 'DWord' -Force
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server' -name 'DisabledByDefault' -value 0 -PropertyType 'DWord' -Force
# Add and Enable TLS 1.0 for client and server SCHANNEL communications
md 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0' -Force
@matejskubic
matejskubic / gist:7be604a7e1c16cdbf8b5
Created May 5, 2014 14:46
Powershell post form with relative / absolute url
$resp = Invoke-WebRequest -Verbose -Uri $url
$selectedForm = $resp.Forms[0]
$webAction = New-Object System.Uri ($resp.BaseResponse.ResponseUri, $selectedForm.Action)
$resp2 = Invoke-WebRequest -Verbose -Uri $webAction -Method $selectedForm.Method -Body $selectedForm
@matejskubic
matejskubic / LastWake.bat
Created June 3, 2014 20:49
What woke the system from the last sleep transition
powercfg -lastwake
@matejskubic
matejskubic / _AreaPageSimulation_.xpo
Created September 18, 2014 08:53
AX 2012 Area Page Form simulation
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: FRM
; Microsoft Dynamics AX Forms unloaded
; --------------------------------------------------------------------------------
FRMVERSION 12
FORM #_AreaPageSimulation_
function Get-LatestDropLocation {
param(
[Parameter(Position=0,Mandatory=$true)] [string]$tfsLocation,
[Parameter(Position=1,Mandatory=$true)] [string]$projectName,
[Parameter(Position=3,Mandatory=$true)] [string]$buildDefinitionName
)
Add-Type -AssemblyName "Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
Add-Type -AssemblyName "Microsoft.TeamFoundation.Build.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
$tfsUri = New-object Uri($tfsLocation)
@matejskubic
matejskubic / DeleteBackupHistory.sql
Created March 9, 2015 15:12
Delete backup history mssql server
set xact_abort on
declare @media_set_id int = 6089
use msdb
begin tran
delete from backupfile
where exists
(select null
from backupset
where backupset.backup_set_id = backupfile.backup_set_id