Skip to content

Instantly share code, notes, and snippets.

@zommarin
Last active January 8, 2016 11:38
Show Gist options
  • Save zommarin/ace045e8b7b75c15d863 to your computer and use it in GitHub Desktop.
Save zommarin/ace045e8b7b75c15d863 to your computer and use it in GitHub Desktop.
# Directory of the current script
$ScriptDir = Split-Path -Parent $myInvocation.MyCommand.Path
# Date stuff
$Date.ToString("yyyyMMdd")
$Date.ToString("yyyy-MM-dd")
# GZip XML Document Read
$FileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $FromFile.FullName, Open, Read
$UnzippedStream = New-Object -TypeName System.IO.Compression.GZipStream -ArgumentList ($FileStream, [System.IO.Compression.CompressionMode]::Decompress)
$StreamReader = New-Object -TypeName System.IO.StreamReader -ArgumentList $UnzippedStream
[xml] $XmlContent = $StreamReader.ReadToEnd()
$StreamReader.Close()
# Edit Console2 Configuration files
e $env:APPDATA\Console\console.xml
function IsInElevatedMode {
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
return (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
# Load the SQL Server snapins (must be done using wildcards as their names differs depending on version)
Get-PSSnapin -Registered SqlServer*Snapin* | Add-PSSnapin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment