Windows Server 2016 で作るシンプルなハイパーコンバージドインフラ (Microsoft TechSummit 2016)Takamasa Maejima
2016年11月に開催された Microsoft TechSummit 2016 での、Windows Server 2016 ストレージ機能 (SDS) を活用したハイパーコンバージドインフラ (HCI) に関するセッションスライドです。
[イベント名] Microsoft TechSummit 2016
[開催日] 2016年11月1日
[セッションID] CDP-002
[セッションタイトル] Windows Server 2016 で作るシンプルなハイパーコンバージドインフラ
Active Directory のクラウド武装化計画 V2~"AD on Azure IaaS" or "Windows Azure Active Di...junichi anno
この資料のPPT版、および AD on IaaS の構築手順書は、以下のキャンペーンサイトから入手してくださいませ。
http://technet.microsoft.com/ja-jp/windowsserver/dn715816
大人の事情でごめんなさい。でも気合い入れて作った手順書です。
66. WMI Scriptingの基本形
'SWbemLocator オブジェクトの作成
Set Locator = CreateObject("WbemScripting.SWbemLocator")
‘ローカルコンピュータへの接続
Set Service = Locator.ConnectServer("", "root¥cimv2", "", "")
‘クエリーの定義(WQL:WMI Query Language)
strQuery = "Select * from Win32_NetworkAdapterConfiguration " & _
"where IPEnabled = True"
‘クエリーの実行(インスタンスを取得する)
Set objNet = Service.ExecQuery(strQuery)
'結果の参照
For each n in objNet
WScript.Echo n.caption
WScript.Echo n.MACAddress
Next
66
67. WMIスクリプトの実行権限
リモートコンピュータに対するゕクセス権の取得
Set Service = Locator.ConnectServer(RemoteHost,Namespace,User,Password)
特殊権限の取得
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer("DC01", "root¥cimv2", "Dom¥administrator", "pass")
Service.Security_.Privileges.AddAsString "SeBackupPrivilege", True
Service.Security_.Privileges.AddAsString "SeSecurityPrivilege", True
strQuery = "Select * from Win32_NTEventlogFile" & _
" Where LogfileName = 'Security' "
Set obj = Service.ExecQuery(strQuery)
For each n in obj
r = n.BackupEventLog("C:¥tmp¥Security.evt")
Next
67
76. 一時的な監視例③
__InstanceCreationEventによるユーザーログオンの監視
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer("demo2008", "ROOT¥CIMV2", "", "")
Wscript.Echo "接続が完了しました"
strQueryCreate = "Select * FROM __InstanceCreationEvent WITHIN 5 " & _
"WHERE TargetInstance ISA 'Win32_LogonSession' ‚
Set objEventsCreation = objService.ExecNotificationQuery(strQueryCreate)
Do
Set CreationEvent = objEventsCreation.Nextevent
LogonId= CreationEvent.TargetInstance.LogonID
LogonType = CreationEvent.TargetInstance.LogonType
strQueryLU = "Select * " & _
‚FROM Win32_LoggedOnUser‛ ' Where Dependent like ‘%" & LogonId & "%’‚
Set objLoggedOnUser = objService.ExecQuery(strQueryLU)
For Each u in objLoggedOnUser
If instr(u.Dependent, LogonId) Then
Wscript.Echo u.Antecedent
ユーザーID
Wscript.Echo u.Dependent
ログオンID
End If
Next
Loop
76
77. 一時的な監視例③‘ (③をブラッシュアップ)
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer("demo2008", "ROOT¥CIMV2", "", "")
Wscript.Echo "接続が完了しました"
strQueryCreate = "Select * FROM __InstanceCreationEvent WITHIN 5 " & _
"WHERE TargetInstance ISA 'Win32_LogonSession' ‚
Set objEventsCreation = objService.ExecNotificationQuery(strQueryCreate)
Do
Set CreationEvent = objEventsCreation.Nextevent
LogonId= CreationEvent.TargetInstance.LogonID
LogonType = CreationEvent.TargetInstance.LogonType
Select Case LogonType
Case 0 strLogonType = "System"
Case 2 strLogonType = "Interactive"
Case 3 strLogonType = "Network"
Case 4 strLogonType = "Batch"
Case 5 strLogonType = "Service"
Case 6 strLogonType = "Proxy"
Case 7 strLogonType = "Unlock"
Case 8 strLogonType = "NetworkClearText"
Case 9 strLogonType = "NewCredentials"
Case 10 strLogonType = "RemoteInteractive(TS)"
Case 11 strLogonType = "CachedInteractive"
Case 12 strLogonType = "CachedRemoteInteractive"
Case 13 strLogonType = "CachedUnlock"
End Select 77
78. strQueryLoggedOnUser = "Select * " & _
"FROM Win32_LoggedOnUser"
Set objLoggedOnUser = objService.ExecQuery(strQueryLoggedOnUser)
For Each u in objLoggedOnUser
If instr(u.Dependent, LogonId) Then
arrAntecedent = Split(u.Antecedent,".")
Wscript.Echo Date & "," & Time & "," & _
LogonId & "," & arrAntecedent(2) & "," & strLogonType
Exit For
End If
Next
Loop
78
79. 一時的な監視例④
__InstanceDeletionEventによるユーザーログオフの監視
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer("demo2008", "ROOT¥CIMV2", "", "")
Wscript.Echo "接続が完了しました"
strQueryCreate = "Select * " & _
"FROM __InstanceDeletionEvent WITHIN 5 " & _
"WHERE TargetInstance ISA 'Win32_LogonSession' "
Set objEventsDeletion = objService.ExecNotificationQuery(strQueryCreate)
Do
Set DeletionEvent = objEventsDeletion.Nextevent
LogonId= DeletionEvent.TargetInstance.LogonID
LogonType = DeletionEvent.TargetInstance.LogonType
Wscript.Echo Date & "," & Time & "," & LogonId & "," & strLogonType
Loop
セッションの削除はログオフしてから1分程度を要する
79
85. 呼び出されるスクリプト(③‘’)
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer("demo2008", "ROOT¥CIMV2", "", "")
Set objFS = CreateObject("Scripting.FileSystemObject")
Wscript.Echo "接続が完了しました"
strQueryCreate = "Select * FROM __InstanceCreationEvent WITHIN 5 " & _
"WHERE TargetInstance ISA 'Win32_LogonSession' ‚
Set objEventsCreation = objService.ExecNotificationQuery(strQueryCreate)
Do
Set CreationEvent = objEventsCreation.Nextevent
LogonId= CreationEventTargetEvvent.TargetInstance.LogonID
LogonType = CreationEventTargetEvent.TargetInstance.LogonType
Select Case LogonType
Case 0 strLogonType = "System"
Case 2 strLogonType = "Interactive"
Case 3 strLogonType = "Network"
Case 4 strLogonType = "Batch"
Case 5 strLogonType = "Service"
Case 6 strLogonType = "Proxy"
Case 7 strLogonType = "Unlock"
Case 8 strLogonType = "NetworkClearText"
Case 9 strLogonType = "NewCredentials"
Case 10 strLogonType = "RemoteInteractive(TS)"
Case 11 strLogonType = "CachedInteractive"
Case 12 strLogonType = "CachedRemoteInteractive"
Case 13 strLogonType = "CachedUnlock"
End Select 85
86. strQueryLoggedOnUser = "Select * FROM Win32_LoggedOnUser"
Set objLoggedOnUser = objService.ExecQuery(strQueryLoggedOnUser)
For Each u in objLoggedOnUser
If instr(u.Dependent, LogonId) Then
arrAntecedent = Split(u.Antecedent,".")
Set objLogFile = objFS.OpenTextFile("C:¥tmp¥demoscript¥userlog.txt",8,True)
objLogFile.WriteLine Date & "," & Time & "," & LogonId & "," & _
arrAntecedent(2) & "," & strLogonType
objLogFile.Close
Wscript.Echo Date & "," & Time & "," & _
LogonId & "," & arrAntecedent(2) & "," & strLogonType
Exit For
End If
Next
Loop
86