Skip to content

Instantly share code, notes, and snippets.

View ebibibi's full-sized avatar

Masahiko Ebisuda ebibibi

View GitHub Profile
@ebibibi
ebibibi / Install-SCOMAgents.ps1
Created November 12, 2013 07:14
This script installs SCOM agents to several clients. ex) .\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
#This script installs SCOM agents to several clients.
#
#ex)
#.\Install-SCOMAgent.ps1 -ServerName scomserver.domain.name -Targets @("client1.domain.name", "client2.domain.name")
Param(
[parameter(mandatory=$true)]$ServerName,
[parameter(mandatory=$true)]$Targets
)
@ebibibi
ebibibi / Set-PowerPlanHigh.ps1
Created November 15, 2013 08:01
電源プランを「高パフォーマンス」に設定します。
$p = Get-CimInstance -Name root\cimv2\power -Class win32_PowerPlan -Filter "ElementName = '高パフォーマンス'"
Invoke-CimMethod -InputObject $p[0] -MethodName Activate
@ebibibi
ebibibi / PowerShell Samples.ps1
Created February 12, 2014 03:48
PowerShell Samples
#test
@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
@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 / 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
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 / DeployIIS.ps1
Created July 17, 2015 23:43
Azure上にAzure Resource Managerを使ってWindows Server複数台を展開(IISの役割は未追加)
#----------------------------------------------------------
#設定
#----------------------------------------------------------
#スクリプトパス
$scriptPath = ""
#サブスクリプション名
$subscriptionName = ""
#リージョン
$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 / 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