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
#Mersenne_twister | |
$MT = New-Object int64[] 624 | |
[int]$index = 0 | |
function Initialize-Generator | |
{ | |
<# | |
Initialize the generator from a seed. | |
#> | |
param( |
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
Function Get-ShuffledArray | |
{ | |
#Given a set of 1000 numbers, how do I shuffle the set in an unbiased way | |
#so that it has the appearance of a randomly generated set? | |
param( | |
[Array]$gnArr | |
) | |
$len = $gnArr.Length; | |
while($len) | |
{ |
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
<# | |
.SYNOPSIS | |
Get data from SQL Server error log | |
.DESCRIPTION | |
The script was created to answer a question on twitter: | |
"How to filter line + following line using Get-SqlErrorLog? | |
Something like Select-String -Context 1" | |
.LINK | |
https://sqlchow.wordpress.com/2013/08/18/filtering-data-from-sqlserver-errorlogs/ | |
.LINK |
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
<# | |
.SYNOPSIS | |
Set SCOM console polling rate. | |
.DESCRIPTION | |
Sets the polling rate of your SCOM console to every 75 seconds from the | |
default polling rate of every 5 seconds. | |
.LINK | |
https://sqlchow.wordpress.com/2013/03/15/setting-scom-console-polling-rate/ | |
.LINK | |
.NOTES |
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
function Get-SQLInstanceList | |
{ | |
<# | |
.SYNOPSIS | |
Get SQL Server instances installed on a local machine | |
.DESCRIPTION | |
The script looks in the registry path | |
HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL\ | |
and will check which SQL*Server instances are installed and for each |
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
<# | |
.SYNOPSIS | |
Get failed backup details from SQL Error log. | |
.DESCRIPTION | |
The script uses SMO to read error log and filters data based on the criteria. | |
.LINK | |
https://sqlchow.wordpress.com/2013/02/13/t-sql-tuesday-39-getting-installed-instances-querying-logs/ | |
.LINK |
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
<# | |
.SYNOPSIS | |
Get errors in windows log for the past 24hrs. | |
.DESCRIPTION | |
The below function will query the windows event logs and return the highest | |
occurring error events along with their counts. | |
.LINK | |
https://sqlchow.wordpress.com/2013/02/13/t-sql-tuesday-39-getting-installed-instances-querying-logs/ |
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
function Get-UnexpectedShutdowns | |
{ | |
<# | |
.SYNOPSIS | |
Checks unexpected shutdowns in the last 24hrs. | |
.DESCRIPTION | |
This script checks if a given computer has been shutdown unexpectedly | |
in the last 24hrs. | |
KB: http://support.microsoft.com/kb/2028504 |
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
function Test-SQLConnection | |
{ | |
<# | |
.Synopsis | |
Test connection to a sql server. | |
.DESCRIPTION | |
The function tries to connect to the SQL Server, if a successful | |
connection is made we return back the server name. | |
You cannot pipe parameter to Test-SQLConnection. |
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
function Get-SMOConnection { | |
<# | |
.SYNOPSIS | |
Create a new SMOConnection Object. | |
.DESCRIPTION | |
The Get-SMOConnection creates new SMO Connection to the SQL Server instance | |
and returns the connection object to the calling function or script. | |
.PARAMETER SqlServer |
OlderNewer