Skip to content

Instantly share code, notes, and snippets.

View guitarrapc's full-sized avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile
@guitarrapc
guitarrapc / DSCPushSample.ps1
Last active August 29, 2015 13:57
DSC Push model Sample for AD Memeber (DSC Sever) to WorkGroup Servers (30 servers). Speed comparison with DSC and Valentia.
# DSC Push のサンプルとして、サーバー30台に対する DSC-Service のWindows 機能インストールを行う
configuration InstallDSCServiceCredential
{
param
(
[PSCredential]
$credential
)
node $AllNodes.NodeName
# Get API Access https://console.developers.google.com/project/projectID/apiui/api?authuser=0
$clientId = "INPUT CLIENT ID for API"
$clientSecret = "CLIENT SECRET for API"
#return to us locally not via a web server
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
$grantType = "authorization_code"
# change scope here, you can use oauth playground to find scopes
@guitarrapc
guitarrapc / Get-HostEntryAsync.ps1
Last active August 29, 2015 14:04
Resolve HostName to IPAddress / IPAddress to HostName
#Requires -Version 3.0
<#
.Synopsis
Get HostName to IPAddress Entry / IPAddress to HostName Entry
.DESCRIPTION
using Dns.GetHostEntryAsync Method.
You can skip Exception for none exist HostNameOrAddress result by adding -SkipException $true
@guitarrapc
guitarrapc / Copy-StrictedFilterFileWithDirectoryStructure.ps1
Last active August 29, 2015 14:05
Copy Selected Extensions, and Directory Structure Only
<#
# Copy "All Directory Structure" and "File" which Extension type is .bat
Copy d:\GitHub\valentia -Destination d:\fuga -Force -Recurse -Filter "*.bat"
# Copy "All Directory Structure" and "File" which Extension type is .md
Copy d:\GitHub\valentia -Destination d:\fuga -Force -Recurse -Filter "*.md"
# If you want to exclude specific file to copy
Get-ChildItem -Path $Destination -Recurse -File | where Name -in Readme_J.md | Remove-Item -Recurse
# Install (simple way)
# Write this code to "%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1"
# Install (module way)
# Place this script to "%USERPROFILE\Documents\WindowsPowerShell\Modules\UseLayoutRounding\UseLayoutRounding.psm1" and
# write "Import-Module UseLayoutRounding" to Microsoft.PowerShellISE_profile.ps1
Add-Type -TypeDefinition @"
using System;
using System.Collections.Generic;
using System.Reflection;
@guitarrapc
guitarrapc / MS14-045CheckPipeline.ps1
Last active August 29, 2015 14:05
MS14-045 issue check by piepline.
$message = "font '{0}' found! Your environmet will trouble with MS14-045. See https://support.microsoft.com/kb/2982791"
$fontregistory = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\'
(Get-Item -Path $fontregistory).Property | % {(Get-ItemProperty -path $fontregistory).$_ | where {$_.EndsWith('.otf')} | where {Test-Path $_} | %{ Write-Host ($message -f $_) -ForegroundColor Red;return}}
Write-Host 'Your environment is OK.'
function Copy-ItemEX
{
[CmdletBinding()]
param
(
[parameter(Mandatory = 1, Position = 0, ValueFromPipeline = 1, ValueFromPipelineByPropertyName =1)]
[alias('PSParentPath')]
[string]$Path,
[parameter(Mandatory = 1, Position = 1, ValueFromPipelineByPropertyName =1)]
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)]