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
#Unable to download the list of available providers. Check your internet connection. | |
# Run this | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Then run Install-Module, f.ex.: | |
Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber |
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
param ( | |
[string]$fileSource = $(throw "-fileSource is required"), | |
[string]$fileDestination = $(throw "-fileDestination is required") | |
) | |
$text = Get-Content $fileSource -Encoding UTF8 -Raw | |
[IO.File]::WriteAllText($fileDestination, $text, [Text.Encoding]::GetEncoding(1252)) |
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
-- Remove last UNION ALL manually | |
SELECT | |
CONCAT( 'SELECT * FROM OPENROWSET(''MSOLAP'', ''Data Source=SERVER;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=', CATALOG_NAME, ''', ''SELECT * FROM $System.DBSCHEMA_TABLES WHERE TABLE_TYPE=''''SYSTEM TABLE'''' '')', ' UNION ALL') | |
FROM OPENROWSET('MSOLAP', 'Data Source=epn-SERVER;Integrated Security=SSPI;Persist Security Info=False;', 'SELECT * FROM $System.DBSCHEMA_CATALOGS ') |
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 C.NAME | |
, CONVERT(NVARCHAR(MAX),CONVERT(XML,CONVERT(VARBINARY(MAX),C.CONTENT))) AS REPORTXML | |
FROM REPORTSERVER.DBO.CATALOG C | |
WHERE C.CONTENT IS NOT NULL | |
AND C.TYPE = 2 |
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
SET NOCOUNT ON; | |
CREATE TABLE #databases( | |
database_id int, | |
database_name sysname | |
); | |
INSERT INTO #databases(database_id, database_name) | |
SELECT database_id, [name] | |
FROM sys.databases |
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
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null | |
$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST" | |
$backupPath = "Q:\backup\" | |
$datetime = Get-Date -Format "yyyyMMdd_HHmmss" | |
foreach ($database in $s.Databases) { | |
$databaseName = $database.Name | |
#Skip databases |
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
Open a command prompt window. If you have a default instance of SQL Server already running, run the following command on the command prompt to stop the SQL Server service: | |
net stop mssqlserver | |
Now go to the directory where SQL server is installed. The directory can for instance be one of these: | |
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn | |
C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn | |
Figure out your MSSQL directory and CD into it as such: | |
CD C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn |
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 s.session_id | |
,r.STATUS | |
,r.blocking_session_id AS 'blocked_by' | |
,r.wait_type | |
,r.wait_resource | |
,CONVERT(VARCHAR, DATEADD(ms, r.wait_time, 0), 8) AS 'wait_time' | |
,r.cpu_time | |
,r.logical_reads | |
,r.reads | |
,r.writes |
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 | |
OBJECT_SCHEMA_NAME(object_id) [SchemanName], | |
OBJECT_NAME(object_id) [TableName], | |
last_user_update, | |
last_user_seek, | |
last_user_scan, | |
last_user_lookup | |
FROM sys.dm_db_index_usage_stats | |
WHERE database_id = DB_ID('SCHEMA_NAME') | |
AND OBJECT_NAME(object_id) = 'TABLE_NAME' |
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
################## | |
# Privacy Settings | |
################## | |
# Privacy: Let apps use my advertising ID: Disable | |
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0 | |
# To Restore: | |
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1 | |
# Privacy: SmartScreen Filter for Store Apps: Disable | |
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0 |