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
#NB: replace "." with instance name (e.g. ".\sqlexpress" or "axlive\sql06") | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null | |
New-Object -typeName Microsoft.SqlServer.Management.Smo.Server(".") | select edition, version |
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
powershell | |
cls | |
function testme { | |
param( | |
[Parameter( | |
Position=0, | |
Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true) |
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
$a = ipconfig | |
$a | |
# Reverse array contents and then output it again: | |
[array]::Reverse($a) | |
$a |
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
Start-Process powershell.exe -Credential "TestDomain\Me" -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs" |
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
--https://holsopple.wordpress.com/2011/02/18/sp_axwho-that-i-use/ | |
USE [DynamicsTest] | |
GO | |
/****** Object: StoredProcedure [dbo].[SP_AXWHO] Script Date: 02/18/2011 14:32:11 ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
ALTER procedure [dbo].[SP_AXWHO] AS |
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
::See http://www.robvanderwoude.com/datetimentparse.php for lots of useful info on dates in batch files. | |
::The script below assumes a locale of UK (i.e. %date% gives DD/MM/YYYY). | |
@echo off | |
::Split date & time into component parts; assumes dd/mm/yyyy | |
FOR /F "TOKENS=1,2,3 DELIMS=/ " %%A IN ('echo %Date%') DO (SET dd=%%A&SET mm=%%B&SET yyyy=%%C) | |
FOR /F "TOKENS=1,2,3 DELIMS=:. " %%A IN ('echo %Time%') DO (SET hh=%%A&SET mi=%%B&SET ss=%%C) | |
::join in order of greatest affector to least (i.e. a year is longer than a month, so comes first) |
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 UI.Name, UI.ID, SR.AOTName, SRC.DATAAREA | |
FROM HarmonyLive.dbo.SecurityUserRole UR | |
LEFT JOIN HarmonyLive_Model.dbo.SecurityRole SR ON SR.RecId = UR.SecurityRole | |
LEFT JOIN HarmonyLive.dbo.UserInfo UI ON UI.Id = UR.User_ and UI.PARTITION = UR.PARTITION | |
left join HarmonyLive.dbo.SecurityUserRoleCondition SRC on SRC.SECURITYUSERROLE = UR.RECID and SRC.PARTITION = UR.PARTITION | |
WHERE UI.Enable = '1' | |
ORDER BY UI.Name, SR.AOTName | |
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
cls | |
$myLog = 'Application' | |
$mySource = 'My PS Script' | |
$myEventId = 1 | |
[System.Diagnostics.EventLogEntryType]$myEntryType = [System.Diagnostics.EventLogEntryType]::Error | |
$myMessage = 'This is a test message' | |
$myMessage2 = 'This is a test message (2)' | |
$myMessage3 = 'This is a test message (3)' | |
function Write-EventLog2 |
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
declare @emptyGuid uniqueidentifier; | |
--instead of having to type: | |
set @emptyGuid= '{00000000-0000-0000-0000-000000000000}' | |
--you can do: | |
set @emptyGuid = cast(cast(0 as binary) as uniqueidentifier) | |
--or even: | |
set @emptyGuid = cast(0x0 as uniqueidentifier) | |
--REF: http://stackoverflow.com/questions/3092999/check-empty-guid-in-sql |
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 Name, @{Name="LabelHere";Expression={$_.Length * 100}} |