Skip to content

Instantly share code, notes, and snippets.

@matejskubic
matejskubic / createSqlSharedAccessSignature.ps1
Last active November 3, 2022 18:08
Generate SQL shared access signature for azure storage account
[CmdletBinding()]
Param(
# subscription name
[parameter()]
[string]$subscriptionName = 'EA - MSDN - AX - ProdDev - 01'
,
# resource group name
[parameter()]
[string]$resourceGroupName='adaxbackup'
@matejskubic
matejskubic / backupToAzure.sql
Created August 17, 2017 07:55
Backup SQL DB to azure
DECLARE @dbToBackup as sysname = 'AxDB'
DECLARE @container as nvarchar(50) = lower(HOST_NAME())
DECLARE @file as nvarchar(100) = @dbToBackup + N'_' + FORMAT(GETDATE(), N'yyyy-MM-dd_hhmmss') + N'.bak'
DECLARE @destUrl as nvarchar(500) = N'https://storageaccount.blob.core.windows.net/' + @container + N'/' + @file
PRINT @destUrl
BACKUP DATABASE @dbToBackup TO
URL = @destUrl
WITH NOFORMAT, NOINIT, NAME = N'Ax-Full Database Backup', NOSKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
GO
### Reference: http://deploymentresearch.com/Research/Post/578/Building-the-perfect-Windows-Server-2016-reference-image
$ISO = "C:\Setup\ISO\Windows Server 2016.iso"
$CU = "C:\Setup\Cumulative Update for Windows Server 2016 for x64-based Systems (KB3201845)\AMD64-all-windows10.0-kb3201845-x64_95e1e765344e1388fee3f7c0c143499e0b617d9f.msu"
$MountFolder = "C:\Mount"
$RefImage = "C:\Setup\REFWS2016-001.wim"
# Verify that the ISO and CU files existnote
if (!(Test-Path -path $ISO)) {Write-Warning "Could not find Windows Server 2016 ISO file. Aborting...";Break}
if (!(Test-Path -path $CU)) {Write-Warning "Cumulative Update for Windows Server 2016. Aborting...";Break}
@matejskubic
matejskubic / wifipass.bat
Created February 6, 2017 08:40
Windows 10 WiFi password
netsh wlan show profiles
netsh wlan show profiles name="%1" key=clear
@matejskubic
matejskubic / 0_reuse_code.js
Created September 13, 2016 15:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@matejskubic
matejskubic / form_init.xpo
Created September 5, 2016 13:52
AX 2012 Form init args diag
anytype a10 = element.args().dataset();
anytype a10str = tableId2name(element.args().dataset());
anytype a11 = element.args().record();
anytype a12 = element.args().refField();
anytype a12str = fieldId2name(element.args().dataset(), element.args().refField());
anytype a13 = element.args().selectField();
anytype a13str = fieldId2name(element.args().dataset(), element.args().selectField());
anytype a20 = element.args().lookupTable();
anytype a20str = tableId2name(element.args().lookupTable());
@matejskubic
matejskubic / MEcount.sql
Last active August 24, 2016 12:20 — forked from anzekrpic/MEcount.sql
AX modelElements in models between build versions
SELECT mf.name,
mf.VersionMajor,
mf.VersionMinor,
mf.VersionBuildNo,
mf.VersionRevision,
COUNT(*) AS 'Element count'
FROM modelelementdata med
JOIN modelmanifest mf ON mf.modelid = med.modelid
WHERE mf.VersionBuildNo BETWEEN 1000 AND 3999
GROUP BY mf.name,
@matejskubic
matejskubic / drop-all-constraints.sql
Created August 2, 2016 08:58
Drop all CONSTRAINTs
select
'ALTER TABLE [' + TABLE_NAME + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']'
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
@matejskubic
matejskubic / EthernetAsMetered.bat
Created June 13, 2016 17:38
How to set an Ethernet Connection as Metered to control Updates, Drivers, Store and others
REM source: https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/how-to-set-an-ethernet-connection-as-metered-to/ecdaca08-d413-4a6a-9e33-b4afb337fc18?auth=1
REM The key is [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost]
REM There are entries under it for 3G, 4G, Default, Ethernet and Wifi. The normal settings for 3G and 4G are 2. For Ethernet and Wifi (and Default) it is 1. 2 means metered, 1 means not metered. So to make Ethernet Metered, the value needs to be changed from 1 to 2.
rem run from install directory
cd /d C:\Program Files\Windows Resource Kits\Tools\
rem change owner to Administrators
rem should report: Done: 1, Modified 1, Failed 0, Syntax errors 0
subinacl /subkeyreg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" /setowner=administrators
@matejskubic
matejskubic / mssql-connections-details.sql
Created December 23, 2015 10:04
SQL Server connections details
select b.spid, b.hostname, b.program_name, a.net_transport, a.auth_scheme
from sys.dm_exec_connections a
inner join sys.sysprocesses b
on a.session_id = b.spid