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-SqlVersionName { | |
param( | |
[Version]$Version | |
) | |
$lookup = @{ | |
'Name' = ('Major', 'Minor', 'RTM', 'SP1', 'SP2', 'SP3', 'SP4') | |
'2016' = ( 13, 0, 1601, 4001 ) | |
'2014' = ( 12, 0, 2000, 4100, 5000 ) | |
'2012' = ( 11, 0, 2100, 3000, 5058, 6020 ) |
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 Remove-Service { | |
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByName')] | |
param ( | |
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'ByName')] | |
[String]$Name, | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'FromPipeline')] | |
[PSTypeName('Microsoft.Management.Infrastructure.CimInstance#root/cimv2/Win32_Service')] | |
[CimInstance]$InputObject, |
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 Resolve-ParameterSet { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[String]$Command, | |
[String[]]$ParameterName | |
) | |
try { |
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
Option Explicit | |
' ContactImport.vbs | |
' | |
' Contact Import / Maintenance Script | |
' | |
' Subroutines | |
' |
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
{ | |
"Id": "ActionTemplates-62", | |
"Name": "OctoPS", | |
"Description": "A PowerShell host implementation with flexible stream redirection.\n\nThe step parameters may be used to set values for the preference variables. The ErrorActionPreference variable is set to Continue by default for all scripts executing within the host.\n\nPreference variables may be set within scripts, overriding any settings defined by the step. Additional output may be requested using the individual parameters for each stream (for example, the Verbose parameter).\n\n**Limitations and known issues**\n\n- Write-Host is not supported except in PowerShell 5 as a wrapper for Write-Information.\n- Several of the IIS commands (Stop-WebSite, Stop-WebAppPool) appear to break the output streams used by the host.", | |
"ActionType": "Octopus.Script", | |
"Version": 13, | |
"CommunityActionTemplateId": null, | |
"Properties": { | |
"Octopus.Action.Script.Syntax": "PowerShell", | |
"Octopus.Action.Script.ScriptSource": "Inline", |
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
# Playing around with: https://blogs.msdn.microsoft.com/powershell/2007/03/03/start-demo-help-doing-demos-using-powershell/ | |
# WIP. | |
function Get-DemoCommand { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[String]$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-ChildProperty { | |
param ( | |
$Object, | |
$Name | |
) | |
$current, $next = $Name -split '\.', 2 | |
if ($next) { | |
Get-ChildProperty $Object.$current $next |
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
class TaskTimeSpan { | |
[Int32]$Years | |
[Int32]$Months | |
[Int32]$Days | |
[Int32]$Hours | |
[Int32]$Minutes | |
[Int32]$Seconds | |
TaskTimeSpan([String]$TimeSpanString) { | |
if ($TimeSpanString -match '^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?') { |
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 Start-Syslog { | |
<# | |
.SYNOPSIS | |
Start a syslog server on the current machine in a new PowerShell session. | |
.DESCRIPTION | |
Start a syslog server on the current machine in a new PowerShell session. | |
#> | |
[CmdletBinding()] | |
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 Remove-Utf8Bom { | |
<# | |
.SYNOPSIS | |
Removes a UTF8 BOM from a file. | |
.DESCRIPTION | |
Removes a UTF8 BOM from a file if the BOM appears to be present. | |
The UTF8 BOM is identified by the byte sequence 0xEF 0xBB 0xBF at the beginning of the file. | |
.EXAMPLE | |
Remove-Utf8Bom -Path c:\file.txt |
OlderNewer