Skip to content

Instantly share code, notes, and snippets.

View kkamegawa's full-sized avatar

KAMEGAWA Kazushi kkamegawa

View GitHub Profile
@kkamegawa
kkamegawa / Show-TaskSchedule.ps1
Created December 13, 2014 02:10
Task Scheduler will run information.
Get-ScheduledTask | Where {$_.State -eq 'Ready'} | Get-ScheduledTaskInfo | where {$_.nextruntime -ne $null} | select taskpath,taskname,nextruntime
@kkamegawa
kkamegawa / Get-OfficeTime.ps1
Created December 13, 2014 22:42
Show working time in office. I checked Vista, and Windwos 7.
$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
kkamegawa / remove-sqllogs.ps1
Last active August 29, 2015 14:12
Remove old SQL Server Transaction log, and Backup log, dump files.
#remove sql server old files
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum")
#create a new server object
$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") "(local)"
$backupDirectory = $server.BackupDirectory
$folders = get-childitem $backupDirectory -Directory
@kkamegawa
kkamegawa / xslxNamespace.cs
Last active August 29, 2015 14:14
Create OpenXML Spreadsheet's xml namespace in LINQ to XML.
using System.Xml.Linq;
namespace XslxNameSpaceSample
{
class Program
{
static void XNamespaceSample()
{
const string openXmlMarkupSchema = "http://schemas.openxmlformats.org/markup-compatibility/2006";
const string spreadSheetSchema = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac";
@kkamegawa
kkamegawa / gist:4240828
Created December 8, 2012 15:58
Deny Itanium patch in Windows Server 2012's WSUS
$wsus = Get-WsusServer -name localhost -PortNumber 8530
$ia64 = $wsus.GetUpdates() | Where-Object {$_.title.indexof("Itanium") -gt 1 -and $_.title.indexof("x64") -eq -1 -and $_.ArrivalDate -gt [datetime]::Now.AddDays(-7)}
foreach($patch in $ia64) {
Get-WsusUpdate -UpdateId $patch.id.updateid | Deny-WsusUpdate
}
$wsus | Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates
@kkamegawa
kkamegawa / gist:4285724
Last active October 14, 2015 01:18
Remove IIS Log file for IIS 7.0/7.5/8.0 after 7 days.
import-module WebAdministration
$iisroot = 'IIS:\Sites\'
$sites = get-itemproperty $iisroot
foreach($site in $sites.children) {
foreach($webroot in $sites.Children.Keys) {
$WebSite = join-path $iisroot $webroot
$logpath = get-itemproperty $WebSite -name logfile.directory.value
if($logpath -ne $null) {
$logpath = [environment]::ExpandEnvironmentVariables($logpath)
$files = get-childitem $logpath -include "*.log" -recurse
@kkamegawa
kkamegawa / list-backupfiles.ps1
Created November 15, 2015 04:00
create backup file list to HTML in Windows Server 2012 R2.
$OnPremisePolicy = Get-WBPolicy
$Backups = @{
Folder = $Folder
FileName = $FileName
}
$BackupList = @()
foreach($backup in $OnPremisePolicy){
@kkamegawa
kkamegawa / 2015-nov-18-vso.md
Last active November 20, 2015 00:52
about Visual Studio Team Services

Connect();でVisual Studio Onlineの大幅な変更がアナウンスされました。いくつか紹介します。元ネタhttps://www.visualstudio.com/en-us/news/2015-nov-18-vso.aspx

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の拡張機能もも見つけることができます。

@kkamegawa
kkamegawa / check-uwphandson.ps1
Last active November 28, 2015 13:10
Check environment for UWP's Hands-on
$COmpornents = @(
@('Microsoft Visual Studio Community 2015','https://go.microsoft.com/fwlink/p/?LinkId=534599'),
@('IDE Tools for Windows 10','https://go.microsoft.com/fwlink/p/?LinkId=619296'),
@('Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.8','http://go.microsoft.com/fwlink/?linkid=699285&clcid=0x411'),
@('Microsoft SQL Server 2014 Express LocalDB','https://www.microsoft.com/ja-jp/download/details.aspx?id=42299'))
if ($PSVersionTable.PSVersion -lt '5.0.10586.0') {
Write-host "Please Install Windows 10 TH2(1511)."
return
}
@kkamegawa
kkamegawa / 2015-nov-24-vso.md
Last active December 5, 2015 16:42
Update information in nov-24 in Japanese

GitとTFVCが同じチームプロジェクトで使えるようになりました

素晴らしいお知らせです!このスプリントで、GitリポジトリにTFVCリポジトリ、もしくはその逆ができるようになりました。これですべてのコードと重要なデータをあなたのチームプロジェクトに簡単に移行することができますし、もちろんビルド定義や作業項目も同じです。

Repository

ビルドタスクにパッケージマネージャが追加

先週のConnect();でVisual Studio Team Servicesで[Package Management](Package Manmagement "http://blogs.msdn.com/b/visualstudioalm/archive/2015/08/27/announcing-package-management-for-vso-tfs.aspx ")が公開され、リリースされたバイナリコンポーネントを安全に共有する機能がVisual Studio Marketplaceから入手することができます。