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 / ToastNotification-Sample.ps1
Last active July 13, 2016 07:46
toast sample in PowerShell not yet finished;
# Code conversion from C# to PowerShell
# http://msdn.microsoft.com/en-us/library/windows/apps/hh802768.aspx
# nuget Windows 7 API Code Pack -Shell
# http://nugetmusthaves.com/Package/Windows7APICodePack-Shell
# Install-Package Windows7APICodePack-Shell
Add-Type -Path .\Microsoft.WindowsAPICodePack.dll
Add-Type -Path .\Microsoft.WindowsAPICodePack.Shell.dll
# create toast template TO xml
@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
@guitarrapc
guitarrapc / Get-ScreenShot.ps1
Last active July 31, 2023 15:21
Screenshot Automation with PowerShell
function Get-ScreenShot
{
[CmdletBinding()]
param(
[parameter(Position = 0, Mandatory = 0, ValueFromPipelinebyPropertyName = 1)]
[ValidateNotNullOrEmpty()]
[string]$OutPath = "$env:USERPROFILE\Documents\ScreenShot",
#screenshot_[yyyyMMdd_HHmmss_ffff].png
[parameter(Position = 1, Mandatory = 0, ValueFromPipelinebyPropertyName = 1)]
@guitarrapc
guitarrapc / Install-PowerShellScriptBrowzerForISE.ps1
Created April 17, 2014 21:15
Install-PowerShellScriptBrowzerForISE
filter Show-LogoutputEX
{
"[{0}][{1}][{2}]" -f ((Get-Date).ToString("yyyy/MM/dd HH:mm:ss")),$_[0], $_[1]
}
function Invoke-ScriptBlockEX ([scriptBlock]$scriptBlock, [string]$WhatDoing)
{
begin
{
$sw = New-Object System.Diagnostics.Stopwatch
# 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)]