Skip to content

Instantly share code, notes, and snippets.

View ebibibi's full-sized avatar

Masahiko Ebisuda ebibibi

View GitHub Profile
@ebibibi
ebibibi / untitled.xml
Created September 2, 2019 01:04
Sample answer file for sysprep of Windows Server 2019(Japanese)
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OOBE>
<HideEULAPage>true</HideEULAPage>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>SampleP@ssw0rd</Value>
@ebibibi
ebibibi / AddRecordToTable.vba
Created May 23, 2019 05:34
Excel VBAにてテーブルにレコードを追加
Sub AddRecordToTable()
Set 購入リストテーブル = Worksheets("購入").ListObjects("購入リストテーブル")
With 購入リストテーブル.ListRows.Add
.Range(1).Value = "商品名"
.Range(2).Value = "100"
.Range(3).Value = "3"
.Range(4).Value = "300"
End With
End Sub
@ebibibi
ebibibi / GetTableInformation.vba
Created May 23, 2019 05:05
Excelにてテーブル内のデータを取得
Sub GetTableInformation()
Set 購入リストテーブル = Worksheets("購入").ListObjects("購入リストテーブル")
For i = 1 To 購入リストテーブル.ListRows.Count
商品名 = 購入リストテーブル.ListColumns("商品名").DataBodyRange(i)
Debug.Print 商品名
単価 = 購入リストテーブル.ListColumns("単価").DataBodyRange(i)
Debug.Print 単価
@ebibibi
ebibibi / ConnectToExchangeOnline.ps1
Created January 23, 2019 01:39
スクリプトにパスワードまで生で記載する形のExchange Onlineへの接続スクリプト(セキュリティには注意)
# Exchange OnlineへのPowerShell接続(※多要素認証には非対応)
#
# 1. O365組織の管理者のIDとパスワードを生で記載する
# 2. 管理者として実行したPowerShellに貼り付ける
# 3. 作業する
# 4. 作業が終わったら Remove-Session $Session を実行する
#
# 参考:https://docs.microsoft.com/ja-jp/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
Set-ExecutionPolicy RemoteSigned
$users = Get-ADUser -Filter * -Properties displayNamePrintable, DisplayName, mail
$displayNamePrintables = $users.displayNamePrintable
$duplicateUsers = $displayNamePrintables | Where-Object {if(($displayNamePrintables -eq $_).count -ge 2){$_}} | Sort-Object | Get-Unique
Write-Output "表示名 `t DisplayNamePrintable `t メールアドレス"
foreach($user in $users)
{
$duplicateUsers | ForEach-Object {
if($user.displayNamePrintable -eq $_)
@ebibibi
ebibibi / DeployIIS.ps1
Created July 17, 2015 23:43
Azure上にAzure Resource Managerを使ってWindows Server複数台を展開(IISの役割は未追加)
#----------------------------------------------------------
#設定
#----------------------------------------------------------
#スクリプトパス
$scriptPath = ""
#サブスクリプション名
$subscriptionName = ""
#リージョン
workflow StopAllVMs
{
$azureCredential = Get-AutomationPSCredential -Name "Default Automation Credential"
# Connect to Azure
Add-AzureAccount -Credential $azureCredential | Write-Verbose
# Select the Azure subscription
$SubscriptionName = 'xxx Subscription Name xxx'
Select-AzureSubscription -SubscriptionName $SubscriptionName
@ebibibi
ebibibi / gist:64ca2cdd0aa1bbb2d516
Last active August 29, 2015 14:03
flickr upload sample1
require 'flickraw'
FlickRaw.api_key=""
FlickRaw.shared_secret=""
flickr.access_token = ""
flickr.access_secret = ""
# From here you are logged:
login = flickr.test.login
@ebibibi
ebibibi / runas.ps1
Created June 16, 2014 03:39
run as administrator in PowerShell
Param
(
[String]$Path = (Get-Location)
)
# Elevate
Write-Host "Checking for elevation... " -NoNewline
$CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
if (($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) -eq $false) {
ArgumentList = "-noprofile -noexit -file `"{0}`" -Path `"$Path`""
@ebibibi
ebibibi / runas.vbs
Created June 16, 2014 03:36
run as administrator in vbscript
do while WScript.Arguments.Count=0 and WScript.Version>=5.7
'Run this script as admin.
Set sha=CreateObject("Shell.Application")
sha.ShellExecute "wscript.exe",""""+WScript.ScriptFullName+""" uac","","runas"
WScript.Quit
loop