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
############################################################################## | |
## BEGIN-HELPER FUNCTIONS ## | |
############################################################################## | |
############################################################################## | |
## Get-RemoteRegistryKeyProperty | |
## Get the value of a remote registry key property | |
## | |
## Author: Lee Holmes | |
## Book: Windows Powershell Cookbook |
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
<# | |
.LINK https://sqlchow.wordpress.com/2012/07/30/creating-a-slipstream-sql-server-install-media-using-powershell/ | |
#> | |
Begin | |
{ | |
$isPCU = $true | |
$isCU = $false | |
$verPCU = "5500" # service pack version | |
$verCU = $null | |
$archArray = @('x64', 'x86', 'ia64') |
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 Move-MouseEveryMin | |
{ | |
$startTime = Get-Date | |
$endTime = Get-Date | |
$timeDiff = New-TimeSpan -Start $startTime -End $endTime | |
$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen | |
$StartPos = [System.Windows.Forms.Cursor]::Position | |
$Pos = $StartPos | |
While($timeDiff.Hours -lt 1) | |
{ |
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-DiskSizes | |
{ | |
<# | |
.SYNOPSIS | |
Get disk sizes | |
.DESCRIPTION | |
The Get-DiskSizes function returns data about the disks on a given machine. | |
It uses Win32_Volume class to get this information. | |
.PARAMETER ComputerName | |
Name of the machine from where we need to retrieve the information. |
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-WMIDirectoryTree | |
{ | |
<# | |
.SYNOPSIS | |
To view a directory tree. | |
.DESCRIPTION | |
The script takes a path and computername and lists the directory | |
tree on that particular computer for that particular path. | |
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-SubnetMask | |
{ | |
<# | |
Address IPv4Mask | |
------- -------- | |
192.168.1.39 255.255.255.0 | |
127.0.0.1 255.0.0.0 | |
PS C:\Users\sqlchow> Get-SubnetMask -address 127.0.0.1 |
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 Add-LoginsToSQLServerAsSysAdmin | |
{ | |
<# | |
.SYNOPSIS | |
Add windows group to sysadmin role | |
.DESCRIPTION | |
The function loops through a list of sql servers and adds a given | |
windows group to the sysadmin role on these servers. | |
.PARAMETER LoginToAdd | |
Name of the windows group that needs to be added in the following format |
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 |
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-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 |