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 Pause ($Message="Press any key to continue...") | |
| { | |
| # The ReadKey functionality is only supported at the console (not in the ISE) | |
| if ($PGSE -eq $null) | |
| { | |
| Write-Host -NoNewLine $Message | |
| $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
| Write-Host "" | |
| } |
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
| # note: requires Web Administration (IIS) Provider for Windows PowerShell | |
| # http://technet.microsoft.com/en-us/library/ee909471(v=ws.10).aspx | |
| cls | |
| try | |
| { | |
| Import-Module WebAdministration | |
| #Get-WebApplication |
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
| # Usage: Audit.ps1 'pathtolistofservers' # | |
| # The file is optional and needs to be a plain text list of computers to be audited one on each line. # | |
| # | |
| param([string] $auditlist) | |
| cls | |
| $Error.Clear() # clear the stack | |
| $targets = $null | |
| if ($auditlist -eq "") |
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
| cls | |
| $source = "\\sourcefiles\path\here"; | |
| $auth = "\\authserver\c$\Fileroot"; | |
| $destDev = "\\devserver\C$\FileRoot"; | |
| $destTest = "\\testserver\C$\FileRoot"; | |
| $destStage = "\\stageserver\C$\FileRoot"; | |
| $destProd = "\\productionserver\C$\FileRoot"; | |
| #$scriptBlock = { Param($source,$destination) robocopy $source $destination /MAXAGE:21 /MT:32 /S /NC /NS /NDL /NJH /NJS /NFL } | |
| $scriptBlock = { Param($source,$destination) robocopy $source $destination /MAXAGE:21 /MT:32 /S } |
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
| private void SetKeepAliveIOControl(Socket socket, uint interval, uint retryInterval, bool enabled) | |
| { | |
| int size = sizeof(UInt32); | |
| uint on = enabled ? (uint)1 : (uint)0; | |
| byte[] inArray = new byte[size * 3]; | |
| Array.Copy(BitConverter.GetBytes(on), 0, inArray, 0, size); | |
| Array.Copy(BitConverter.GetBytes(interval), 0, inArray, size, size); | |
| Array.Copy(BitConverter.GetBytes(retryInterval), 0, inArray, size * 2, size); | |
| socket.IOControl(IOControlCode.KeepAliveValues, inArray, null); | |
| } |
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
| param([parameter(Mandatory=$true,HelpMessage="Server Environment")]$state,$env) | |
| Import-Module WebAdministration; | |
| switch ($env) | |
| { | |
| "### SERVERNAME ###" | |
| { | |
| if ($state -eq "STOP") | |
| { |
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
| DECLARE @SQL VARCHAR(MAX) | |
| DECLARE @SearchString VARCHAR(100) | |
| SET @SQL = '' | |
| SET @SearchString = 'some string here' | |
| SELECT @SQL = @SQL + 'SELECT CONVERT(VARCHAR(MAX),COUNT(*)) + '' matches in column ''+''' | |
| + C.name + '''+'' on table '' + ''' + SC.name + '.' + T.name + | |
| ''' [Matches for '''+@SearchString+''':] FROM ' + | |
| QUOTENAME(SC.name) + '.' + QUOTENAME(T.name) + ' WHERE ' + QUOTENAME(C.name) + |
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
| $website = 'Default' | |
| $server = 'SOME_SERVER_01' | |
| $session = New-PSSession -ComputerName $server -Name "My_Session_Name" | |
| $remoteOriginalFolder = Invoke-Command -Session $session -ScriptBlock { param($website) | |
| Import-Module WebAdministration | |
| $originalFolder = Get-WebFilePath IIS:\Sites\$website | |
| return $originalFolder.FullName | |
| } -ArgumentList $website | |
| $remoteOriginalFolder |
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
| cls | |
| [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") | |
| [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client") | |
| $serverName = "http://server.fqdn:8080/tfs" | |
| $teamProject = "project_name" | |
| $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName) | |
| $buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) | |
| $buildDefinitions = $buildServer.QueryBuildDefinitions($teamProject).Name |
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
| // Init: Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(); | |
| // hierarchy.Root.AddAppender(CreateWSMFileAppender("logger-name-here")); | |
| // Usage: var wsmLog = LogManager.GetLogger("logger-name-here"); | |
| // if (wsmLog != null) | |
| // { | |
| // wsm.InfoFormat("Hi, you did it dynamically!"); | |
| // { | |
| private static IAppender CreateFileAppender(string appenderName) | |
| { |
OlderNewer