Skip to content

Instantly share code, notes, and snippets.

View mkht's full-sized avatar

mkht

  • Japan
  • 06:14 (UTC +09:00)
View GitHub Profile
$CSCode = @'
using System;
using System.Runtime.InteropServices;
public static class Security
{
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct SID_IDENTIFIER_AUTHORITY
{
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]
$ErrorActionPreference = 'Stop'
$WarningPreference = 'Stop'
$Description = ('RestorePoint created by CRP task ({0})' -f [datetime]::Now.ToString('yyyy/MM/dd-hh:mm:ss'))
try {
Enable-ComputerRestore -Drive C:\
Checkpoint-Computer -Description $Description
}
catch {
exit 0x80040205 #INTERNALEXCEPTION
<# =======================================================
ストアアプリ再登録スクリプト 2019/07/12
for Windows 10 64bit Version 1809
======================================================= #>
$ErrorActionPreference = 'Continue'
$ProgressPreference = 'SilentlyContinue'
# Get all apps list
$Apps = Get-AppxPackage -ErrorAction Stop
@mkht
mkht / publish.ps1
Last active September 5, 2018 12:01
Publish script for PowerShell Gallery
Param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$NugetApiKey,
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string[]]$ExcludeDirs = @('.git', '.vscode'),
[Parameter(Mandatory = $false)]
@mkht
mkht / Remove-EnvironmentPath.ps1
Created July 18, 2018 13:49
環境変数PATHから指定の値を削除する
<# ++++++++++++++++++++++++++++++++++++++++++++++
環境変数PATHから指定の値を削除する
+++++++++++++++++++++++++++++++++++++++++++++++++ #>
function Remove-EnvironmentPath {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, Position = 0)]
[string] $Path, # 削除する値
[Parameter(Mandatory = $true, Position = 1)]
@mkht
mkht / Add-EnvironmentPath.ps1
Created July 18, 2018 13:48
環境変数PATHの末尾に指定の値を追加する
<# ++++++++++++++++++++++++++++++++++++++++++++++
環境変数PATHの末尾に指定の値を追加する
+++++++++++++++++++++++++++++++++++++++++++++++++ #>
function Add-EnvironmentPath {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, Position = 0)]
[string] $Path, # 追加する値
[Parameter(Mandatory = $true, Position = 1)]
@mkht
mkht / AccessorClass.ps1
Created January 18, 2018 15:21
PowerShell class accessor
# Original code
# https://stackoverflow.com/questions/39717230/powershell-class-implement-get-set-property
# This technique is so impressive!
class c {
hidden $_p = $($this | Add-Member ScriptProperty 'p' `
{
# get
"getter $($this._p)"
}`
{
@mkht
mkht / gist:f4fde36c633c6c68278180e3e66261e7
Created November 27, 2017 12:57
Photoshopの関連付けを64bit版に直すスクリプト
$PS32 = 'C:\Program Files (x86)\Adobe\Adobe Photoshop CC 2018 (32 Bit)\Photoshop.exe'
$PS64 = 'C:\Program Files\Adobe\Adobe Photoshop CC 2018\Photoshop.exe'
gci HKLM:\SOFTWARE\Classes | ? {$_.Name -match 'Photoshop'} | gci -Recurse | gp | ? {$_.'(default)'.contains($PS32)} | % { sp -Path $_.PSPath -Name '(default)' -Value $_.'(default)'.Replace($PS32,$PS64)}
@mkht
mkht / LayoutModification_taskbar.xml
Created October 13, 2017 15:29
Windows10用スタートメニューレイアウト(タスクバーレイアウト付き)
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout">
<LayoutOptions StartTileGroupCellWidth="6" StartTileGroupsColumnCount="1" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="ブラウザ">
<start:DesktopApplicationTile Size="2x2" Column="0" Row="0" DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Accessories\Internet Explorer.lnk" />
<start:Tile Size="2x2" Column="2" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
<start:DesktopApplicationTile Size="2x2" Column="0" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk"
@mkht
mkht / LayoutModification.xml
Created October 13, 2017 15:28
Windows10用スタートメニューレイアウト
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" StartTileGroupsColumnCount="1" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="ブラウザ">
<start:DesktopApplicationTile Size="2x2" Column="0" Row="0" DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Accessories\Internet Explorer.lnk" />
<start:Tile Size="2x2" Column="2" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
<start:DesktopApplicationTile Size="2x2" Column="0" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk" />
<start:DesktopApplicationTile Size="2x2" Column="2" Row=