Skip to content

Instantly share code, notes, and snippets.

Avatar

KAMEGAWA Kazushi kkamegawa

View GitHub Profile
@kkamegawa
kkamegawa / gist:9035191
Created Feb 16, 2014
Install-WindowsFeature for TFS
View gist:9035191
Install-WindowsFeature -name Web-Common-Http,Web-Windows-Auth,Web-Basic-auth,Web-Performance,Web-Dyn-Compression,Web-Net-Ext,Web-Net-Ext45,Web-AppInit,Web-Asp-Net,Web-Asp-Net45,Web-ISAPI-Filter,Web-ISAPI-Ext,Web-WebSockets,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Scripting-Tools,Web-Mgmt-Service,AS-NET-Framework,AS-Web-Support,AS-WAS-Support,FS-FileServer,NET-Framework-Features,NET-Framework-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-Framework-45-ASPNET,NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45,ManagementOData,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,WinRM-IIS-Ext,Web-Request-Monitor,Web-Http-Tracing -source d:\sources\sxs
@kkamegawa
kkamegawa / gist:9052606
Created Feb 17, 2014
Setting Windows Update timing for PowerShell
View gist:9052606
$AutoUpdate = new-object -ComObject "Microsoft.Update.AutoUpdate"
# 4 is Scheduled Install
# Be carefull.If you enabled Group Policy when setting NotificationLevel is abort.
$AutoUpdate.Settings.NotificationLevel = 4
# 0 is EveryDay
$AutoUpdate.Settings.ScheduledInstallationDay = 0
# 0 is 0:00 AM
$AutoUpdate.Settings.ScheduledInstallationTime = 0
$AutoUpdate.Settings.save()
View gist:7d50a2b4e37be0646d84
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;
namespace LogBlock
{
class Program
{
public void FlatText()
{
@kkamegawa
kkamegawa / gist:88ac2220b31be925b44b
Last active Aug 29, 2015
PowerShell for Windows patch apply
View gist:88ac2220b31be925b44b
$patches = get-item $foldername
$process = new-object System.Diagnostics.Process
foreach($patch in $patches){
if($PSVersionTable.PSVersion.Major -ge 4) {
unblock-file $patch
}
if([string]::compare($patch.extension, ".exe", $true) -eq 0) {
$process.StartInfo.Arguments = "/passive /norestart"
$process.StartInfo.FileName = $patch.fullname
}else if([string]::compare($patch.extension, ".msu", $true) -eq 0) {
View MS14-045check.ps1
$fontregistory = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\'
$fonts = get-item -Path $fontregistory | Select-Object -expandProperty Property
foreach($font in $fonts){
$fontpath = get-ItemProperty -path $fontregistory | select-Object -property $font
#if font path is full path and exist
$FontExist = Test-Path $fontpath.$font
if($FontExist -eq $true){
if($fontpath.$font.EndsWith('.otf', $true, $null) -eq $true){
Write-Host "Your environmet will trouble with MS14-045. See https://support.microsoft.com/kb/2982791"
return
@kkamegawa
kkamegawa / AuthenticationProxySetting.xml
Last active Aug 29, 2015
Use Authentication proxy in .NET Program.append this section in exe.config file.
View AuthenticationProxySetting.xml
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy usesystemdefault="True"/>
</defaultProxy>
<settings>
<ipv6 enabled="true"/>
</settings>
</system.net>
@kkamegawa
kkamegawa / Reset-Nic.ps1
Created Nov 24, 2014
Reset Network Adapter for Windows 8.1/Windows Server 2012 R2
View Reset-Nic.ps1
#Reset Network Adapter for Windows 8.1/Windows Server 2012 R2
Diable-NetAdapter -name "Local Area Network" -confirm:$false
Enable-NetAdapter -name "Local Area Network" -confirm:$false
@kkamegawa
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
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="http://schemas.microsoft.com/windows/2004/02/mit/task" version="1.4">
<RegistrationInfo>
<Date>2014-12-01T04:34:23.796031</Date>
<Author>.\administrator</Author>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<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
kkamegawa / backup-vmdisk-2008r2.ps1
Created Dec 4, 2014
Hyper-V's VHD backup only Windows Server 2008 R2. Use http://pshyperv.codeplex.com.
View backup-vmdisk-2008r2.ps1
#this script can run under pshyperv.codeplex.com'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'