Author(s)
Thirumalaa Srinivas
Jon Hass
Programmatic scripting with WSMAN
This Dell Technical White Paper provides information about
programming scripts with WSMAN.
This white paper is for informational purposes only, and may contain typographical errors and technical
inaccuracies. The content is provided as is, without express or implied warranties of any kind.
This document is for informational purposes only and may contain typographical errors and
technical inaccuracies. The content is provided as is, without express or implied warranties of
any kind.
© 2012 Dell Inc. All rights reserved. Dell and its affiliates cannot be responsible for errors or
omissions in typography or photography. Dell, the Dell logo, and PowerEdge are trademarks of Dell
Inc. Intel and Xeon are registered trademarks of Intel Corporation in the U.S. and other countries.
Microsoft, Windows, and Windows Server are either trademarks or registered trademarks of Microsoft
Corporation in the United States and/or other countries. Other trademarks and trade names may be
used in this document to refer to either the entities claiming the marks and names or their products.
Dell disclaims proprietary interest in the marks and names of others.
April 2012| Rev 1.0
1 Scripting WSMAN Operating System Deployment – Boot Network ISO
Contents
Executive Summary................................................................................ 3
Introduction......................................................................................... 3
WSMAN clients ...................................................................................... 3
WinRM CLI ........................................................................................ 3
OpenWSMAN CLI ................................................................................. 4
Scripting WSMAN clients using Python ......................................................... 5
Common APIs ....................................................................................... 6
Detect Host Operating System................................................................ 7
Construct WSMAN CLI commands ............................................................ 7
Enumerate .................................................................................... 7
Enumerate Keys ............................................................................. 8
Get ............................................................................................. 9
Set ............................................................................................ 10
Invoke ........................................................................................ 11
Launch WSMAN CLI command ................................................................ 12
Ping test ......................................................................................... 12
Extract SSL certificate ........................................................................ 13
Important Notes ................................................................................... 14
Where to Find More Information ............................................................... 14
Summary ........................................................................................... 15
2 Scripting WSMAN Operating System Deployment – Boot Network ISO
Executive Summary
This white paper is for systems administrators looking to program scripts with WSMAN clients and to
harness the power of the secure and standards-based WSMAN service.
Introduction
Dell PowerEdge servers equipped with Integrated Dell Remote Access Controller (iDRAC) provide
secure, simple, scriptable and standards-based remote management capability through Web Services
for Management (WSMAN). WSMAN is a management transport protocol that enables a user to access
systems management data objects and methods supported by the target platform. You can utilize the
WSMAN interface by scripting WSMAN using command-line tools such as winrm on Windows and
wsmancli on Linux. WSMAN can also be accessed from scripting languages like Python, which can run
on both Windows and Linux. You may need to read specification documents to understand the
terminology and concept in this document. If you are a systems administrator that typically works
with command-line tools and scripts, then this white paper should benefit you.
This document helps you:
(A) Get started on programmatically scripting with WSMAN using Python.
(B) Learn common APIs to leverage in your custom scripts.
WSMAN clients
There are two primary WSMAN clients described in this document:
Windows Remote Management (WinRM) CLI for Windows
OpenWSMAN CLI for Linux
Both these WSMAN clients are equivalent in most of their feature set. They allow usage of most of
the high frequency and high usage WSMAN operations. Reference the WinRM and OpenWSMAN CLI
sections for sample output of the command-line tool’s help menu.
You can find more information on installation and usage of these CLI tools in the Where to Find More
Information section. The section contains links to official reference guides from the CLI tool
providers.
WinRM CLI
Sample output of WinRM CLI invocation.
C:\>winrm
Windows Remote Management Command Line Tool
3 Scripting WSMAN Operating System Deployment – Boot Network ISO
Windows Remote Management (WinRM) is the Microsoft implementation of
the WS-Management protocol which provides a secure way to communicate
with local and remote computers using web services.
Usage:
winrm OPERATION RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...]
[@{KEY=VALUE[;KEY=VALUE]...}]
For help on a specific operation:
winrm g[et] -? Retrieving management information.
winrm s[et] -? Modifying management information.
winrm c[reate] -? Creating new instances of management resources.
winrm d[elete] -? Remove an instance of a management resource.
winrm e[numerate] -? List all instances of a management resource.
winrm i[nvoke] -? Executes a method on a management resource.
winrm id[entify] -? Determines if a WS-Management implementation is
running on the remote machine.
winrm quickconfig -? Configures this machine to accept WS-Management
requests from other machines.
winrm configSDDL -? Modify an existing security descriptor for a URI.
winrm helpmsg -? Displays error message for the error code.
For help on related topics:
winrm help uris How to construct resource URIs.
winrm help aliases Abbreviations for URIs.
winrm help config Configuring WinRM client and service settings.
winrm help certmapping Configuring client certificate access.
winrm help remoting How to access remote machines.
winrm help auth Providing credentials for remote access.
winrm help input Providing input to create, set, and invoke.
winrm help switches Other switches such as formatting, options, etc.
winrm help proxy Providing proxy information.
OpenWSMAN CLI
Sample output of OpenWSMAN CLI invocation.
[user@hostname ~]# wsman -?
Usage:
wsman [Option...] <action> <Resource Uri>
Help Options
-?, --help
--help-all Show help options
--help-enumeration Enumeration Options
--help-tests Test Cases
--help-cim CIM Options
--help-flags Request Flags
4 Scripting WSMAN Operating System Deployment – Boot Network ISO