Skip to content

Instantly share code, notes, and snippets.

View guitarrapc's full-sized avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile
function New-ZipPairs
{
[CmdletBinding()]
param
(
[parameter(
Mandatory = 1,
Position = 0,
ValueFromPipelineByPropertyName = 1)]
$key,
@guitarrapc
guitarrapc / New-Empty.ps1
Created August 20, 2014 15:01
LINQ Enumerable.Empty in PowerShell
function New-Empty ([string]$type)
{
$def = @"
public static System.Collections.Generic.IEnumerable<$type> Empty()
{
System.Collections.Generic.IEnumerable<$type> empty = System.Linq.Enumerable.Empty<$type>();
return empty;
}
"@
try
@guitarrapc
guitarrapc / New-Zip.ps1
Created August 21, 2014 00:50
LINQ Enumerable.Zip in PowerShell, more C# like enumerated. : https://github.com/guitarrapc/PowerShellUtil/blob/master/LINQ/New-Zip.ps1
function New-Zip
{
[CmdletBinding()]
param
(
[parameter(
Mandatory = 0,
Position = 0,
ValueFromPipeline = 1,
ValueFromPipelineByPropertyName = 1)]
@guitarrapc
guitarrapc / PipelineExecutionStyles.ps1
Created September 5, 2014 12:05
PowerShell Pipeline Programming Style sample
function PipelineExecuteOnEndProcessingStyle
{
param
(
[parameter(Position = 0, Mandatory = 1, ValueFrompipeline = 1, ValueFromPipelineByPropertyName = 1)]
[string]$hostaddress
)
begin{ $hostaddresses = @() }
process
{
@guitarrapc
guitarrapc / valentiaTypeSample.ps1
Last active August 29, 2015 14:06
valentia Type sample with C#
Add-Type -TypeDefinition @"
public enum ValentiaBranchPath
{
Application = 1,
Deploygroup = 2,
Download = 3,
Maintenance = 4,
Upload = 5,
Utils = 6
}
@guitarrapc
guitarrapc / ValentiaTypeSampleV5.ps1
Created September 7, 2014 22:02
Valentia TypeSample with PowerShell v5
Enum ValentiaBranchPath
{
Application = 1
Deploygroup = 2
Download = 3
Maintenance = 4
Upload = 5
Utils = 6
}
@guitarrapc
guitarrapc / PowershellConstructor.ps1
Last active August 29, 2015 14:06
PowerShell Class Constructor Sample
########################
# Constructor Call check
########################
class Hoge
{
Hoge()
{
Write-Host "constuctor called"
}
}
@guitarrapc
guitarrapc / PowerShellClassSamples.ps1
Last active August 29, 2015 14:06
PowerShell Class Samples
Class CopyItemClass
{
[string]$Path
[string]$Destination
[string]$Item
[PSObject] SetItem([string]$Path, [string]$Destination)
{
$result = copy-Item -Path $Path -Destination $Destination -PassThru
Write-Warning ("Item Copied from {0} to {1}" -f $Path, $Destination)