Skip to content

Instantly share code, notes, and snippets.


KAMEGAWA Kazushi kkamegawa

View GitHub Profile
kkamegawa / Reset-HWNIC.ps1
Last active Aug 29, 2015
Reset Hardware NIC
View Reset-HWNIC.ps1
if ([System.Diagnostics.EventLog]::SourceExists("PowerShellScriptEvent") -eq $false){
New-EventLog -LogName Application -Source PowerShellScriptEvent
Get-NetAdapterHardwareInfo | Restart-NetAdapter -Confirm:$false
Write-EventLog -LogName Application -EntryType Error -Source PowerShellScriptEvent -EventId 1 -Message "Reset HW NIC"
kkamegawa / Reset-HWNICTask.xml
Created Nov 30, 2014
Call Reset-HWNIC.ps1 task on Server start delay 15 min.
View Reset-HWNICTask.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task xmlns="" version="1.4">
<Subscription><QueryList><Query Id="0" Path="System"><Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Kernel-General'] and EventID=12]]</Select></Query></QueryList></Subscription>
kkamegawa / backup-vmdisk-2008r2.ps1
Created Dec 4, 2014
Hyper-V's VHD backup only Windows Server 2008 R2. Use
View backup-vmdisk-2008r2.ps1
#this script can run under's module
Import-Module 'C:\Program Files\modules\HyperV'
if ([System.Diagnostics.Eventing]::sourceExists('PowerShellScript') -eq $false){
new-eve -logname Application -source 'PowerShellScript'
[string]$message = ""
#hyper-v's vm name can only NTFS's compatibile name
$targets = 'Server1','Server2'
#backup root folder
$destinationRoot = 'E:\HyperVBackup'
kkamegawa / Show-TaskSchedule.ps1
Created Dec 13, 2014
Task Scheduler will run information.
View Show-TaskSchedule.ps1
Get-ScheduledTask | Where {$_.State -eq 'Ready'} | Get-ScheduledTaskInfo | where {$_.nextruntime -ne $null} | select taskpath,taskname,nextruntime
kkamegawa / Get-OfficeTime.ps1
Created Dec 13, 2014
Show working time in office. I checked Vista, and Windwos 7.
View Get-OfficeTime.ps1
$date = [datetime]::today.adddays(-1)
$events = Get-EventLog -LogName system -before $date | where-object {$_.source.startswith("Microsoft-Windows-Kernel") -eq $true -or $_.source.startswith("Microsoft-Windows-Power") -eq $true} | select-object timegenerated,source,InstanceID
$poweron = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-General" -and $_.InstanceID -eq 12}
$shutdown = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-General" -and $_.InstanceID -eq 13}
$sleepwakeup = $events | where-object {$_.source -eq "Microsoft-Windows-Power-Troubleshooter" -and $_.InstanceID -eq 1}
$sleepgo = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-Power" -and $_.InstanceID -eq 42}
$workend = $shutdown[0].TimeGenerated
if($sleepgo -ne $null) {
if($shutdown[0].TimeGenerated -lt $sleepgo[0].TimeGenerated) {
kkamegawa / remove-sqllogs.ps1
Last active Aug 29, 2015
Remove old SQL Server Transaction log, and Backup log, dump files.
View remove-sqllogs.ps1
#remove sql server old files
#create a new server object
$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") "(local)"
$backupDirectory = $server.BackupDirectory
$folders = get-childitem $backupDirectory -Directory
kkamegawa / xslxNamespace.cs
Last active Aug 29, 2015
Create OpenXML Spreadsheet's xml namespace in LINQ to XML.
View xslxNamespace.cs
using System.Xml.Linq;
namespace XslxNameSpaceSample
class Program
static void XNamespaceSample()
const string openXmlMarkupSchema = "";
const string spreadSheetSchema = "";
kkamegawa / Choice-AzureSubscription.ps1
Last active Feb 14, 2017
Choice Azure Subscription PowerShell Script
View Choice-AzureSubscription.ps1
function Choice-AzureSubscription
$appdata = [environment]::GetFolderPath("Applicationdata")
$jsonFile = Join-Path $appdata -childpath "Windows Azure Powershell" | join-path -ChildPath "AzureProfile.json"
$json = get-content $jsonFile -encoding UTF8 -raw | ConvertFrom-Json
if($json.Subscriptions.Count -gt 1) {
for($index = 0;$index -lt $json.Subscriptions.Count;$index++){
write-host $index ":" $json.Subscriptions[$index].Name
kkamegawa / list-backupfiles.ps1
Created Nov 15, 2015
create backup file list to HTML in Windows Server 2012 R2.
View list-backupfiles.ps1
$OnPremisePolicy = Get-WBPolicy
$Backups = @{
Folder = $Folder
FileName = $FileName
$BackupList = @()
foreach($backup in $OnPremisePolicy){
kkamegawa /
Last active Nov 20, 2015
about Visual Studio Team Services

Connect();でVisual Studio Onlineの大幅な変更がアナウンスされました。いくつか紹介します。元ネタ

Visual Studio Team Serviceになりました

Visual Studio Onlineという名前でしたが、本日付でVisual Studio Team Servicesに変わります。以前Visual Studio 2008のころはVisual Studio Team Systemという名前でしたが、略称は同じVSTSということですね(^^;。 URLおよび、VS OnlineはブラウザベースのIDEとしてのVisualStudio.comはそのまま生き残ります。


Visual Studio Team Servicesでは今日からMarketPlaceをサポートします。拡張機能はTeam Serviceに統合され、既存の機能を拡張します。カスタムコントロール、コンテキストメニュー、ダッシュボードのウィジェット、ビルド、リリースタスクなどを拡張することができます。

マーケットプレイスではVisual Studioの新しい機能を見つけることができます。Visual Studio Team ServicesとVisual Studio Codeの拡張機能もも見つけることができます。