1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect...
-
Upload
gervase-allison -
Category
Documents
-
view
222 -
download
0
Transcript of 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect...
![Page 1: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/1.jpg)
1
Building Manageable Apps: Admin Scripting & AutomationJeffrey SnoverManagement ArchitectMicrosoft [email protected]
Session Code: ARC-334
![Page 2: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/2.jpg)
2
Make the connection
Base ServicesBase Services
KernelKernel
Hardware Abstraction LayerHardware Abstraction Layer
Base Operating System Services
CLR
Health & InstrumentationHealth & Instrumentation
Management Services
System.Management.InstrumentationSystem.Management.Instrumentation
System.ManagementSystem.Management
System.DiagnosticsSystem.Diagnostics
System.Diagnostics.EventsSystem.Diagnostics.Events
System.Management.MonitoringSystem.Management.Monitoring
Task & AutomationTask & Automation
System.Management.TaskSchedulerSystem.Management.TaskScheduler
System.Management.AutomationSystem.Management.Automation
System.Management.TaskScheduler.UISystem.Management.TaskScheduler.UI
Settings & ConfigurationSettings & Configuration
System.Configuration.SettingsSystem.Configuration.Settings
![Page 3: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/3.jpg)
3
Windows
DSI Architecture (ARC230)Design for OperationsDSI Architecture (ARC230)Design for Operations
Dynamic System Services
SDMStore
Dynamic Data CenterSTORAGESTORAGESERVERSSERVERS NETWORKINGNETWORKING
Settings ARC333
Tasks ARC334
Health ARC332
Hardware
ManagedNode
ManagedSystem
ManagementTools
DevTools
LocalNodeMgm
t
System Level Management
Remote
Node Mgmt
Your Application
Your System
DefinitionSDM
Service
![Page 4: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/4.jpg)
4
Task-Based ManagementTask-Based Management
Abstractions match activities of the userAdd a user – canonical example
Create account in ADCreate home directoryAdd to GroupsCustomer-specific setup…
Surfaced to enable automationRequires command line access!
Abstractions match activities of the userAdd a user – canonical example
Create account in ADCreate home directoryAdd to GroupsCustomer-specific setup…
Surfaced to enable automationRequires command line access!
![Page 5: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/5.jpg)
5
IntroductionIntroduction
Weak cmd shellWeak languagespotty coverage
GUI focusHard to automate
SDK FocusProgrammers
Weak cmd shellWeak languagespotty coverage
GUI focusHard to automate
SDK FocusProgrammers
Foundation for task-based managementFocused on power users and adminsProvides:
Interactive shellCmdletsUtilitiesScripting language Remote scripting
Foundation for task-based managementFocused on power users and adminsProvides:
Interactive shellCmdletsUtilitiesScripting language Remote scripting
Solution: MSHProblem
![Page 6: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/6.jpg)
6
MSH ElementsMSH Elements
Core conceptsPipelines and utilitiesParameters and confirmation Records and errorsNavigation
Core conceptsPipelines and utilitiesParameters and confirmation Records and errorsNavigation
![Page 7: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/7.jpg)
7
Core ConceptsCore Concepts
Command line scripting languageBest of sh/ksh, Perl/Ruby, DCL/CL
Commands are classes (Cmdlets)Hosting model
Command line scripting languageBest of sh/ksh, Perl/Ruby, DCL/CL
Commands are classes (Cmdlets)Hosting model
![Page 8: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/8.jpg)
8
…using
public class{ public override void { (Process.GetProcesses()); }}
System.Management.Automation
Commands Are ClassesCommands Are Classes
GetPs : Cmdlet
[CmdletDeclaration("get", "ps")]
WriteObjects
StartProcessing()
![Page 10: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/10.jpg)
10
How It Works How It Works
AutoRegistration
Parser maps to your DLL
MSH manages the DLL and Class lifecycle
AutoRegistration
Parser maps to your DLL
MSH manages the DLL and Class lifecycle
![Page 11: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/11.jpg)
11
Pipeline And Utilities ConceptsPipeline And Utilities Concepts
1. Pipelines are Cmdlets passing structured objects
2. Reflection-based utility Cmdlets
1. Pipelines are Cmdlets passing structured objects
2. Reflection-based utility Cmdlets
![Page 12: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/12.jpg)
12
Pipeline & Utilities Or…Was That All I Got For 5 Lines Of Code?
James TruherMSH Program [email protected]
![Page 13: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/13.jpg)
13
How It WorksHow It Worksget/process | where “handlecount –gt 500” | sort handlecount | format/table
GetP
roc
ess
Cla
ss
Common MSH Parser
MSH Pipeline ProcessorW
here
C
lass
Sort
Cla
ss
Form
at
Cla
ss
![Page 14: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/14.jpg)
14
CLIs And GUIsCLIs And GUIs
Not either/orAdmins need more than GUIs typically deliver
Planning & reviewGuaranteed consistencyMassive productivity
You need to support both
Not either/orAdmins need more than GUIs typically deliver
Planning & reviewGuaranteed consistencyMassive productivity
You need to support both
Background
![Page 15: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/15.jpg)
15
Composable ManagementComposable Management
Traditional ModelA | B | CTight coupling between
Parse, Get, Process, Output
Relies on parsing text
.NET allows us to do betterFiner grain pipelineObjects instead of text
Traditional ModelA | B | CTight coupling between
Parse, Get, Process, Output
Relies on parsing text
.NET allows us to do betterFiner grain pipelineObjects instead of text
Background
![Page 16: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/16.jpg)
16
CostBenefits
# of Functions
TraditionalModel
EconomicsEconomics
Costs: Dev Test Training
MSH Common Enginecombined with Utility Cmdlets
New Model
Background
![Page 17: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/17.jpg)
17
Glide PathGlide Path
ShowScript
Reflection
Background
GUI
Cmd
VS
![Page 19: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/19.jpg)
19
Parameter And ConfirmationConcepts
Parameter And ConfirmationConcepts
Common parser
Driven by fields/properties + attributes
Use Confirmation model
Common parser
Driven by fields/properties + attributes
Use Confirmation model
![Page 20: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/20.jpg)
20
Parameters And ConfirmationParameters And Confirmation[CommandDeclaration("stop", "ps")]public class StopPs: Cmdlet{
public string ProcessName; public override void ProcessRecord() { Process [ ]ps; ps = Process.GetProcessesByName(ProcessName); foreach (Process p in ps) {
{ p.Kill(); } } }}
[CommandDeclaration("stop", "ps")]public class StopPs: Cmdlet{
public string ProcessName; public override void ProcessRecord() { Process [ ]ps; ps = Process.GetProcessesByName(ProcessName); foreach (Process p in ps) {
{ p.Kill(); } } }}
[ParsingMandatoryParameter][ParsingPromptString(“Name of the process")]
if (ConfirmProcessing(p.ProcessName))
![Page 21: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/21.jpg)
21
Parameters/Confirmation Or… So What Do Those 3 Lines Of Code Get Me?
James TruherMSH Program [email protected]
![Page 22: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/22.jpg)
22
How It WorksParameter AttributesHow It WorksParameter Attributes
PrerequisiteMachineRolePrerequisiteUserRolePrerequisteScriptPrerequisiteUIType ParsingParameterParsingAllowPipelineInputParsingParameterMappingParsingVariableLengthParameterListParsingInteraction
PrerequisiteMachineRolePrerequisiteUserRolePrerequisteScriptPrerequisiteUIType ParsingParameterParsingAllowPipelineInputParsingParameterMappingParsingVariableLengthParameterListParsingInteraction
ParsingPasswordParameter ParsingPromptStringValidationRange ValidationLength ValidationCount ValidationFileAttributesValidationNetworkAttribute ValidationPatternExpandWildcards
ParsingPasswordParameter ParsingPromptStringValidationRange ValidationLength ValidationCount ValidationFileAttributesValidationNetworkAttribute ValidationPatternExpandWildcards
Predicates Parsing Data ValidationData Generation Data Presentation
![Page 23: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/23.jpg)
23
How It WorksHow It Workspublic bool ConfirmProcessing(string Action){
}
if (Confirm){ return Prompt(Action + “Continue [y/n/!]”);}
if (Whatif){ WriteLine(“# “ + Action); return false}
if (Confirm){ return Prompt(Action + “Continue [y/n/!]”);}
if (Verbose){ Writeline(Action); return true;}
if (Whatif){ WriteLine(“# “ + Action); return false}
Pseudo-code
![Page 24: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/24.jpg)
24
Records And Errors ConceptsRecords And Errors Concepts1. MSH is Record oriented
Records come from the Cmdline or the PipeLine
Parameters define or contribute to a record
Pipeline objects are processed into Records
2. Errors are first class citizensPolicy driven error handling
1. MSH is Record orientedRecords come from the Cmdline or the PipeLine
Parameters define or contribute to a record
Pipeline objects are processed into Records
2. Errors are first class citizensPolicy driven error handling
![Page 25: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/25.jpg)
25
[CommandDeclaration("format", "ps")]public class FormatPs: Command{ public string ProcessName; public int HandleCount; public override void StartProcessing() { WriteObject(“Caution – data may be false”); }
public override void EndProcessing() { WriteObject(“Done”)); }}
[CommandDeclaration("format", "ps")]public class FormatPs: Command{ public string ProcessName; public int HandleCount; public override void StartProcessing() { WriteObject(“Caution – data may be false”); }
public override void EndProcessing() { WriteObject(“Done”)); }}
Record OrientationRecord Orientation
public override void ProcessRecord() {
WriteObject(ProcessName + “:” + HandleCount); }
public override void ProcessRecord() {
WriteObject(ProcessName + “:” + HandleCount); }
if (record++ > 5 && record < 10)WriteErrorObject(CurrentPipelineObject,
new Exception("Invalid record"));
[ParsingAllowPipelineInput]
[ParsingAllowPipelineInput]
![Page 26: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/26.jpg)
26
Records And Errors Or …Why This Isn’t Like Your Dad’s Shell
James TruherMSH Program [email protected]
![Page 27: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/27.jpg)
27
How It WorksHow It Works
StartProcessing()
for each object Pipeline
Convert object into a record Apply command line params
ProcessRecord()
EndProcessing()
StartProcessing()
for each object Pipeline
Convert object into a record Apply command line params
ProcessRecord()
EndProcessing()
![Page 28: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/28.jpg)
28
Ubiquitous NavigationUbiquitous Navigation
FileSystems are easy to useNavigation and manipulation are universal
Other stores are hard Require domain-specific utilties and concepts
How do we make other stores easy?Interact with them like FileSystems
FileSystems are easy to useNavigation and manipulation are universal
Other stores are hard Require domain-specific utilties and concepts
How do we make other stores easy?Interact with them like FileSystems
![Page 29: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/29.jpg)
29
Navigation Provider Concepts Navigation Provider Concepts 1. You Subclass and we provide the
CmdletsDir, cd, pushd, popd, cat, delete, rename, copy, clear,
2. Providers need to be registered
3. Requests to providers are stateless and use absolute names
1. You Subclass and we provide the Cmdlets
Dir, cd, pushd, popd, cat, delete, rename, copy, clear,
2. Providers need to be registered
3. Requests to providers are stateless and use absolute names
![Page 30: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/30.jpg)
30
Navigation ProviderNavigation Provider
[ProviderDeclaration("REG", "Registry",ProviderCapabilityFlags.None)]public class RegistryProvider : NavigationCmdletBase{ protected override void GetItem(string path) { RegistryKey key = GetRegkeyForPath(path, false);
if (key == null) { WriteErrorObject(path,
new ArgumentException("does not exist")); } WriteObject(key); } ....}
[ProviderDeclaration("REG", "Registry",ProviderCapabilityFlags.None)]public class RegistryProvider : NavigationCmdletBase{ protected override void GetItem(string path) { RegistryKey key = GetRegkeyForPath(path, false);
if (key == null) { WriteErrorObject(path,
new ArgumentException("does not exist")); } WriteObject(key); } ....}
![Page 31: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/31.jpg)
31
Navigation Provider – OrWhat Whackball Would TreatRegistry Like A Filesystem?
James TruherMSH Program [email protected]
![Page 32: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/32.jpg)
32
How It WorksHow It Works
MSH Engine
Core Command Base Classes
Core Commands(get, set, rename, move, push, pop, …)
FileSysProvider
Cmdlet Cmdlet Cmdlet …
RegistryProvider
ADProvider
![Page 33: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/33.jpg)
33
Longhorn Command Shell (MSH) PreviewLonghorn Command Shell (MSH) Preview
Available on http://betaplace.com
Use the guest account: mshPDC Logon and password emailed within 24 hours
Download bits, SDK, samples, private newsgroup and a feedback/bug reporting environment.
Available on http://betaplace.com
Use the guest account: mshPDC Logon and password emailed within 24 hours
Download bits, SDK, samples, private newsgroup and a feedback/bug reporting environment.
![Page 34: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/34.jpg)
34
Call To ActionCall To Action
1. Write managed code interfaces to your services and objects
2. Design your task model3. Write Cmdlets for invariant
actions4. Write MSH scripts for actions
which vary between customers5. Write Navigation providers to
expose namespaces
1. Write managed code interfaces to your services and objects
2. Design your task model3. Write Cmdlets for invariant
actions4. Write MSH scripts for actions
which vary between customers5. Write Navigation providers to
expose namespaces
![Page 35: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/35.jpg)
35
HAPPY BIRTHDAY ToJIM TRUHER
HAPPY BIRTHDAY ToJIM TRUHER
![Page 36: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/36.jpg)
36© 2003-2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
![Page 37: 1 Building Manageable Apps: Admin Scripting & Automation Jeffrey Snover Management Architect Microsoft Corporation jsnover@microsoft.com Jeffrey Snover.](https://reader036.fdocuments.in/reader036/viewer/2022062809/5697bfa41a28abf838c96e4a/html5/thumbnails/37.jpg)