This file contains hidden or 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
| function Get-MongoEventLog ( | |
| [Parameter(Position=0)][string] $Regex = '.*', | |
| [Parameter(Position=1)][string] $Log = $null | |
| ) | |
| { | |
| # Check to see if we are running the 64 bit version of Powershell. | |
| # See http://stackoverflow.com/questions/2897569/visual-studio-deployment-project-error-when-writing-to-registry | |
| if ([intptr]::size -eq 8) { $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; } | |
| else { $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; } |
This file contains hidden or 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
| $ps = New-Object System.Diagnostics.ProcessStartInfo | |
| $ps.FileName = 'explorer' | |
| $ps.Arguments = '/select, ' + $Path | |
| [System.Diagnostics.Process]::Start($ps) |
This file contains hidden or 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
| Find = chr(34) | |
| Str = "This is string with " & chr(34) & "double quotes" & chr(34) & "." | |
| Occurrences = (Len(Str) - Len(Replace(Str,Find,Empty)) / Len(Find)) | |
| MsgBox "String: " & Str & vbCrLf &_ | |
| "Contains :" & Occurrences & " occurrences of: " & Find & "." | |
| Function GetOccurrences(InputString,LookupString) | |
| If _ | |
| IsNull(InputString) Or IsEmpty(InputString) Or _ | |
| IsNull(LookupString) Or IsEmpty(LookupString) _ |
This file contains hidden or 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
| Function CreateCSV(InputMessageName,OutputMessageName,Delimiter) | |
| Set sb = Application.CreateStringBuilder | |
| If IsNull(Delimiter) OR IsEmpty(Delimiter) Then | |
| Delimiter = ";" | |
| End If | |
| If IsNull(OutputMessageName) OR IsEmpty(OutputMessageName) Then | |
| OutputMessageName = "CSV" | |
| End If |
This file contains hidden or 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
| Function IfNull(Expression,Replacement) | |
| if IsNull(Expression) then | |
| IfNull = Replacement | |
| Else | |
| IfNull = Expression | |
| End If | |
| End Function |
This file contains hidden or 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
| Function InvokePS(Command) | |
| cmd = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command " & Command | |
| Set shell = CreateObject("WScript.Shell") | |
| Set executor = shell.Exec(cmd) | |
| executor.StdIn.Close | |
| InvokePS = executor.StdOut.ReadAll | |
| End Function | |
| Output = REPLACE(InvokePS(Command),vbCrLf,"") |
This file contains hidden or 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
| -- Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64) Jun 17 2016 19:14:09 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor) | |
| set nocount on | |
| go | |
| set cursor_close_on_commit off | |
| go | |
| if object_id('tempdb..#t', 'U') is not null | |
| drop table #t | |
| create table #t (num int) | |
| insert #t values (1),(2),(3),(4); |
This file contains hidden or 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
| DBCC USEROPTIONS; --for user options | |
| @@OPTIONS; --for server options | |
| SET NOCOUNT ON | |
| DECLARE @options INT | |
| SELECT @options = @@OPTIONS | |
| PRINT @options | |
| IF ( (1 & @options) = 1 ) PRINT 'DISABLE_DEF_CNST_CHK' |
This file contains hidden or 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
| Function MatchRegex(RegexPattern,InputString) | |
| If _ | |
| IsNull(RegexPattern) Or IsEmpty(RegexPattern) Or _ | |
| IsNull(InputString) Or IsEmpty(InputString) _ | |
| Then | |
| MatchRegex = False | |
| Else | |
| Set objRegEx = CreateObject("VBScript.RegExp") | |
| objRegEx.Global = True | |
| objRegEx.Pattern = RegexPattern |
This file contains hidden or 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
| Function FindInArray(InputArray,LookupValue) | |
| Dim Found: Found = False | |
| For i = 0 To UBound(InputArray) | |
| If InputArray(i) = LookupValue Then | |
| Found = True | |
| Exit For | |
| End If | |
| Next | |
| FindInArray = Found | |
| End Function |