Skip to content

Instantly share code, notes, and snippets.

View derekmurawsky's full-sized avatar

Derek Murawsky derekmurawsky

View GitHub Profile
@derekmurawsky
derekmurawsky / gist:7751196
Created December 2, 2013 15:31
Enable CLR in MSSQL
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
@derekmurawsky
derekmurawsky / gist:7751173
Last active December 30, 2015 00:39
Add BUILTIN\Administrators as a sysadmin is MSSQL. This was broken/fixed, depending on your POV, in newer versions of SQL server. This will restore it. Be aware, this is a security risk and was changed for a reason.
EXEC sp_grantlogin 'BUILTIN\Administrators'
EXEC sp_addsrvrolemember 'BUILTIN\Administrators','sysadmin'
@derekmurawsky
derekmurawsky / gist:7582042
Created November 21, 2013 14:03
This command line option will force outlook to rebuild folder names if they have been changed to another language... Yes, this actually happened once.
# One of the many useful command line options discussed here: http://office.microsoft.com/en-us/outlook-help/command-line-switches-for-outlook-2010-HP010354956.aspx
outlook.exe /resetfoldernames
@derekmurawsky
derekmurawsky / gist:7581990
Created November 21, 2013 13:59
Icons not displaying properly in Windows? Use this procedure to rebuild your icon cache.
From: http://www.sevenforums.com/tutorials/49819-icon-cache-rebuild.html
ie4uinit.exe -ClearIconCache
taskkill /IM explorer.exe /F
DEL "%localappdata%\IconCache.db" /A
shutdown /r /f /t 00
@derekmurawsky
derekmurawsky / gist:7553658
Last active December 28, 2015 19:58
web.config file to redirect to HTTPS, and a subdirectory. Disables HTTPS redirect for remoting layer. Redirects WWW.domain.com to https://domain.com
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Root Hit Redirect" enabled="false" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
@derekmurawsky
derekmurawsky / gist:7548383
Last active December 28, 2015 19:09
SQL statement to add a local Windows user to SQL server, and then add them to all databases as a datareader. Note: uses sp_addrolemember which is depreciated in post-2012. I haven't found a way to do this manually in < 2012 as the alter role command doesn't support adding a user.
DECLARE @UserName sysname;
DECLARE @NameToAdd sysname;
DECLARE @S nvarchar(1000)
SET @UserName = 'User Name';
SET @NameToAdd = @@SERVERNAME + '\' + @UserName;
-- Create a login using windows auth
--set @s = 'CREATE LOGIN ' + quotename(@NameToAdd) + ' FROM WINDOWS;'
--exec (@S)
@derekmurawsky
derekmurawsky / CreateUserAndAddToGroup
Created November 19, 2013 15:29
Create a user and add them to a group via the Windows command line and net command.
net user UserName Password /ADD /FULLNAME:"Full Name" /PASSWORDCHG:Yes /EXPIRES:never /ACTIVE:yes /COMMENT:"Comment"
net localgroup GroupName UserName /add