Skip to content

Instantly share code, notes, and snippets.

View Pyromaniaxxx's full-sized avatar

Pyromania Pyromaniaxxx

  • Japan
View GitHub Profile
@Pyromaniaxxx
Pyromaniaxxx / SetLicense
Last active August 29, 2015 14:03
テスト投稿(Office 365 License assign)
$LicenseOption = New-MsolLicenseOptions -AccountSkuId $DisablePlanSKUID -DisabledPlans $PlanName
Set-MsolUserLicense -UserPrincipalName $UPN -AddLicenses $AssignLicenseSKU -LicenseOptions $LicenseOption
@Pyromaniaxxx
Pyromaniaxxx / ConnectO365
Last active August 29, 2015 14:03
Connect Office 365
## 接続情報
$user = "hogehoge@hoge.onmicrosoft.com"
$pass = "pasuwa-do"
## Credential 生成
$str = ConvertTo-SecureString $pass -AsPlainText -Force
$psc = New-Object System.Management.Automation.PsCredential($user, $str)
$O365Cred = Get-Credential -Credential $psc
## 接続
@Pyromaniaxxx
Pyromaniaxxx / ConnectLyncOnline
Created June 26, 2014 06:52
Lync Online に接続する PowerShell
$user = “hogehoge@hoge.onmicrosoft.com”
$pass = “pass”
$CTSS = ConvertTo-SecureString $pass -AsPlainText -Force
$PSC = New-Object System.Management.Automation.PsCredential($user, $CTSS)
$O365LyncCred = Get-Credential -Credential $PSC
Import-Module LyncOnlineConnector
$LyncSession = New-CsOnlineSession -Credential $O365LyncCred
Import-PSSession $LyncSession
@Pyromaniaxxx
Pyromaniaxxx / Get-SCVMHost
Created March 4, 2015 08:51
SCVMMで管理している全てのホストにいる仮想マシンの一覧作成的なアレ
#参考
Import-Module -Name virtualmachinemanager
$Hostname = "<<HostName>>"
Get-SCVMHost -VMMServer $Hostname |ForEach-Object {$_.VMs }|Select-Object Name,VMHost,Cloud,VMAddition
Get-SCVMHost -VMMServer $Hostname |ForEach-Object {$_.VMs }|Select-Object Name,VMHost,Cloud,VMAddition|OGV
Get-SCVMHost -VMMServer $Hostname |ForEach-Object {$_.VMs }|Select-Object Name,VMHost,Cloud,VMAddition,VMCPath|FT
Get-SCVMHost -VMMServer $Hostname |ForEach-Object {$_.VMs }|Select-Object Name,VMHost,Cloud,VMAddition,VMCPath|OGV
@Pyromaniaxxx
Pyromaniaxxx / DeviceNaming.ps1
Last active August 29, 2015 14:21
Device NamingとPowerShell Directを組み合わせたテスト
# initialize
[string]$GuestVMName = 'WSTP2_02'
[int]$cnt = 1
$PSList = $null
# Create login credential
$Sstr = ConvertTo-SecureString "password1!" -AsPlainText -Force
$psc = New-Object System.Management.Automation.PsCredential("Administrator", $Sstr)
$Cred = Get-Credential -Credential $psc
@Pyromaniaxxx
Pyromaniaxxx / Get-IsoMaoutVMs
Created December 19, 2015 07:59
ISOをマウントしているVMの一覧を取得する
# SCVMM LibraryのISOを FileShareでmountしていると ライブラリ更新時に「iso を更新できません。ファイルは別のプロセスによって使用されています。」
# と表示されるが、実際どのVMがmountしているかわからないので、ISOをmountしているVMの一覧を抽出する
Get-SCVirtualMachine | ? {$_.VirtualDVDDrives.ISOId -ne $null} | SELECT NAME
@Pyromaniaxxx
Pyromaniaxxx / Set-WMIHandlesPerHost.ps1
Last active April 7, 2016 08:09
WMI ハンドル数の上限値変更
# get wmi object
$obj=get-wmiobject -Namespace root -Class __ProviderHostQuotaConfiguration
# current settings
Write-Host -Object ("HandlesPerHost:{0}" -f $obj.HandlesPerHost)
# update object
$obj.HandlesPerHost = 8192
$obj.Put()
# get wmi object
@Pyromaniaxxx
Pyromaniaxxx / Deploy-NestedAzureStack.ps1
Created April 12, 2016 19:08
Nested Azure Stack 環境を展開するためのスクリプト的な何か
<#
.DESCRIPTION
Nested Azure Stack Deployment Script
.EXAMPLE
.\Deploy-NestedAzureStack.ps1 -Verbose
.EXAMPLE
.\Deploy-NestedAzureStack.ps1 -Verbose -VMName "HostName" -Remove
.EXAMPLE
.\Deploy-NestedAzureStack.ps1 -VMName "MAS" -CPUCore 32 -RAMSize 184 -DiskSize 200 -Verbose
.INPUTS
@Pyromaniaxxx
Pyromaniaxxx / Set-NATvSwitch.ps1
Created April 21, 2016 20:39
NATVMがフリーズする問題を回避するため、NATvSwitchへの迂回路を作るスクリプト
# NATVM Credential
$LoginUser = "Administrator"
$LoginPass = "NATVMPassword"
$Sstr = ConvertTo-SecureString $LoginPass -AsPlainText -Force
$psc = New-Object System.Management.Automation.PsCredential($LoginUser, $Sstr)
$Cred = Get-Credential -Credential $psc
#create nat vSwitch
$SubnetPrefix = "192.168.255.0/24"
@Pyromaniaxxx
Pyromaniaxxx / Create-Win10InstallUSB.ps1
Last active January 8, 2017 21:40
Windows 10 インストール用USBメディア作るスクリプト
$DriveLetter = "Z"
$USBDeviceFriendlyName = "Generic USB Flash Disk"
$ISOPath = "D:\ISOs\ja_windows_10_multiple_editions_xxx.iso"
Get-Disk | where FriendlyName -EQ $USBDeviceFriendlyName | Clear-Disk -RemoveData -PassThru | New-Partition -UseMaximumSize -IsActive -DriveLetter $DriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel USB -Force;
Mount-DiskImage $ISOPath;
$DVDDriveLetter = (Get-DiskImage $ISOPath | Get-Volume).DriveLetter;
Copy-Item "$($DVDDriveLetter):\*" "$($DriveLetter):\" -Recurse -Force -Verbose;