neulab/tldr huggingface dataset:
salt.modules.win_iis.create_binding(site, hostheader='', ipaddress='*', port=80, protocol='http', sslflags=None) Create an IIS Web Binding.
NOTE: This function only validates against the binding ipaddress:port:hostheader combination, and will return True even if the binding already exists with a different configuration. It will not modify the configuration of an existing binding.
• hostheader (str) -- The host header of the binding. Usually a hostname.
• ipaddress (str) -- The IP address of the binding.
• port (int) -- The TCP port of the binding.
• protocol (str) -- The application protocol of the binding.
• sslflags (str) -- The flags representing certificate type and storage of the binding.
salt '*' win_iis.create_binding site='site0' hostheader='example.com' ipaddress='*' port='80'
salt.modules.win_iis.create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslflags=0) Assign a certificate to an IIS Web Binding.
NOTE: The web binding that the certificate is being assigned to must already exist.
• name (str) -- The thumbprint of the certificate.
• hostheader (str) -- The host header of the binding.
• sslflags (int) -- Flags representing certificate type and certificate storage of the binding.
salt '*' win_iis.create_cert_binding name='AAA000' site='site0' hostheader='example.com' ipaddress='*' port='443'
salt.modules.win_iis.create_site(name, sourcepath, apppool='', hostheader='', ipaddress='*', port=80, protocol='http') Create a basic website in IIS.
NOTE: This function only validates against the site name, and will return True even if the site already exists with a different configuration. It will not modify the configuration of an existing site.
• name (str) -- The IIS site name.
• sourcepath (str) -- The physical path of the IIS site.
• hostheader (str) -- The host header of the binding. Usually the hostname or website name, ie: www.contoso.com
• protocol (str) -- The application protocol of the binding. (http, https, etc.)
Returns True if successful, otherwise False.
NOTE: If an application pool is specified, and that application pool does not already exist, it will be created.
salt '*' win_iis.create_site name='My Test Site' sourcepath='c:\stage' apppool='TestPool'
salt.modules.win_iis.create_vdir(name, site, sourcepath, app='/') Create an IIS virtual directory.
NOTE: This function only validates against the virtual directory name, and will return True even if the virtual directory already exists with a different configuration. It will not modify the configuration of an existing virtual directory.
• name (str) -- The virtual directory name.
• app (str) -- The IIS application.
salt '*' win_iis.create_vdir name='vd0' site='site0' sourcepath='C:\inetpub\vdirs\vd0'
salt.modules.win_iis.get_container_setting(name, container, settings) Get the value of the setting for the IIS container.
• name (str) -- The name of the IIS container.
• container (str) -- The type of IIS container. The container types are: AppPools, Sites, SslBindings
• settings (dict) -- A dictionary of the setting names and their values.
Returns A dictionary of the provided settings and their values.
salt '*' win_iis.get_container_setting name='MyTestPool' container='AppPools' settings="['processModel.identityType']"
salt.modules.win_iis.get_webapp_settings(name, site, settings) New in version 2017.7.0.
Get the value of the setting for the IIS web application.
NOTE: Params are case sensitive
• name (str) -- The name of the IIS web application.
• site (str) -- The site name contains the web application. Example: Default Web Site
• settings (str) -- A dictionary of the setting names and their values.  Available settings: physicalPath, applicationPool, userName, password
salt '*' win_iis.get_webapp_settings name='app0' site='Default Web Site' settings="['physicalPath','applicationPool']"
salt.modules.win_iis.get_webconfiguration_settings(name, settings) Get the webconfiguration settings for the IIS PSPath.
• name (str) -- The PSPath of the IIS webconfiguration settings.
• settings (list) -- A list of dictionaries containing setting name and filter.
Returns A list of dictionaries containing setting name, filter and value.
salt '*' win_iis.get_webconfiguration_settings name='IIS:\' settings="[{'name': 'enabled', 'filter': 'system.webServer/security/authentication/anonymousAuthentication'}]"
salt.modules.win_iis.list_apppools() List all configured IIS application pools.
Returns A dictionary of IIS application pools and their details.
salt '*' win_iis.list_apppools
salt.modules.win_iis.list_apps(site) Get all configured IIS applications for the specified site.
Parameters site (str) -- The IIS site name.
Returns: A dictionary of the application names and properties.
salt '*' win_iis.list_apps site
salt.modules.win_iis.list_backups() List the IIS Configuration Backups on the System.
NOTE: Backups are made when a configuration is edited. Manual backups are stored in the $env:Windir\System32\inetsrv\backup folder.
Returns A dictionary of IIS Configurations backed up on the system.
salt '*' win_iis.list_backups
salt.modules.win_iis.list_bindings(site) Get all configured IIS bindings for the specified site.
Parameters site (str) -- The name if the IIS Site
Returns A dictionary of the binding names and properties.
salt '*' win_iis.list_bindings site
salt.modules.win_iis.list_cert_bindings(site) List certificate bindings for an IIS site.
salt.modules.win_iis.list_sites() List all the currently deployed websites.
Returns A dictionary of the IIS sites and their properties.
salt '*' win_iis.list_sites
salt.modules.win_iis.list_vdirs(site, app='/') Get all configured IIS virtual directories for the specified site, or for the combination of site and application.
Returns A dictionary of the virtual directory names and properties.
salt '*' win_iis.list_vdirs site
salt.modules.win_iis.list_worker_processes(apppool) Returns a list of worker processes that correspond to the passed application pool.
Parameters apppool (str) -- The application pool to query
Returns A dictionary of worker processes with their process IDs
salt '*' win_iis.list_worker_processes 'My App Pool'
salt.modules.win_iis.modify_binding(site, binding, hostheader=None, ipaddress=None, port=None, sslflags=None) Modify an IIS Web Binding. Use site and binding to target the binding.
• binding (str) -- The binding to edit. This is a combination of the IP address, port, and hostheader. It is in the following format: ipaddress:port:hostheader. For example, *:80: or *:80:salt.com
• hostheader (str) -- The host header of the binding. Usually the hostname.
The following will seat the host header of binding *:80: for site0 to example.com
salt '*' win_iis.modify_binding site='site0' binding='*:80:' hostheader='example.com'
salt.modules.win_iis.modify_site(name, sourcepath=None, apppool=None) Modify a basic website in IIS.
salt '*' win_iis.modify_site name='My Test Site' sourcepath='c:\new_path' apppool='NewTestPool'
salt.modules.win_iis.remove_app(name, site) Remove an IIS application.
• name (str) -- The application name.
salt '*' win_iis.remove_app name='app0' site='site0'
salt.modules.win_iis.remove_apppool(name) Remove an IIS application pool.
salt '*' win_iis.remove_apppool name='MyTestPool'
salt.modules.win_iis.remove_backup(name) Remove an IIS Configuration backup from the System.
Parameters name (str) -- The name of the backup to remove
salt '*' win_iis.remove_backup backup_20170209
salt.modules.win_iis.remove_binding(site, hostheader='', ipaddress='*', port=80) Remove an IIS binding.
salt '*' win_iis.remove_binding site='site0' hostheader='example.com' ipaddress='*' port='80'
salt.modules.win_iis.remove_cert_binding(name, site, hostheader='', ipaddress='*', port=443) Remove a certificate from an IIS Web Binding.
NOTE: This function only removes the certificate from the web binding. It does not remove the web binding itself.
salt '*' win_iis.remove_cert_binding name='AAA000' site='site0' hostheader='example.com' ipaddress='*' port='443'
salt.modules.win_iis.remove_site(name) Delete a website from IIS.
Parameters name (str) -- The IIS site name.
NOTE: This will not remove the application pool used by the site.
salt '*' win_iis.remove_site name='My Test Site'
salt.modules.win_iis.remove_vdir(name, site, app='/') Remove an IIS virtual directory.
salt '*' win_iis.remove_vdir name='vdir0' site='site0'
salt.modules.win_iis.restart_apppool(name) Restart an IIS application pool.
salt '*' win_iis.restart_apppool name='MyTestPool'
salt.modules.win_iis.restart_site(name) Restart a Web Site in IIS.
Parameters name (str) -- The name of the website to restart.
salt '*' win_iis.restart_site name='My Test Site'
salt.modules.win_iis.set_container_setting(name, container, settings) Set the value of the setting for an IIS container.
salt '*' win_iis.set_container_setting name='MyTestPool' container='AppPools' settings="{'managedPipeLineMode': 'Integrated'}"
salt.modules.win_iis.set_webapp_settings(name, site, settings) New in version 2017.7.0.
Configure an IIS application.
NOTE: This function only configures an existing app. Params are case sensitive.
• settings (str) -- A dictionary of the setting names and their values.  - physicalPath: The physical path of the webapp.  - applicationPool: The application pool for the webapp.  - userName: "connectAs" user - password: "connectAs" password for user
salt '*' win_iis.set_webapp_settings name='app0' site='site0' settings="{'physicalPath': 'C:\site0', 'apppool': 'site0'}"
salt.modules.win_iis.set_webconfiguration_settings(name, settings) Set the value of the setting for an IIS container.
• settings (list) -- A list of dictionaries containing setting name, filter and value.
salt '*' win_iis.set_webconfiguration_settings name='IIS:\' settings="[{'name': 'enabled', 'filter': 'system.webServer/security/authentication/anonymousAuthentication', 'value': False}]"
salt.modules.win_iis.start_apppool(name) Start an IIS application pool.
Parameters name (str) -- The name of the App Pool to start.
salt '*' win_iis.start_apppool name='MyTestPool'
salt.modules.win_iis.start_site(name) Start a Web Site in IIS.
Parameters name (str) -- The name of the website to start.
salt '*' win_iis.start_site name='My Test Site'
salt.modules.win_iis.stop_apppool(name) Stop an IIS application pool.
Parameters name (str) -- The name of the App Pool to stop.
salt '*' win_iis.stop_apppool name='MyTestPool'
salt.modules.win_iis.stop_site(name) Stop a Web Site in IIS.
Parameters name (str) -- The name of the website to stop.
salt '*' win_iis.stop_site name='My Test Site'
salt.modules.win_ip The networking module for Windows based systems
salt.modules.win_ip.disable(iface) Disable an interface
salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2'
salt.modules.win_ip.enable(iface) Enable an interface
salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2'
salt.modules.win_ip.get_all_interfaces() Return configs for all interfaces
salt -G 'os_family:Windows' ip.get_all_interfaces
salt.modules.win_ip.get_default_gateway() Set DNS source to DHCP on Windows
salt -G 'os_family:Windows' ip.get_default_gateway
salt.modules.win_ip.get_interface(iface) Return the configuration of a network interface
salt -G 'os_family:Windows' ip.get_interface 'Local Area Connection'
salt.modules.win_ip.get_subnet_length(mask) Convenience function to convert the netmask to the CIDR subnet length
salt -G 'os_family:Windows' ip.get_subnet_length 255.255.255.0
salt.modules.win_ip.is_disabled(iface) Returns True if interface is disabled, otherwise False
salt -G 'os_family:Windows' ip.is_disabled 'Local Area Connection #2'
salt.modules.win_ip.is_enabled(iface) Returns True if interface is enabled, otherwise False
salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2'
salt.modules.win_ip.raw_interface_configs() Return raw configs for all interfaces
salt -G 'os_family:Windows' ip.raw_interface_configs
salt.modules.win_ip.set_dhcp_all(iface) Set both IP Address and DNS to DHCP
salt -G 'os_family:Windows' ip.set_dhcp_all 'Local Area Connection'
salt.modules.win_ip.set_dhcp_dns(iface) Set DNS source to DHCP on Windows
salt -G 'os_family:Windows' ip.set_dhcp_dns 'Local Area Connection'
salt.modules.win_ip.set_dhcp_ip(iface) Set Windows NIC to get IP from DHCP
salt -G 'os_family:Windows' ip.set_dhcp_ip 'Local Area Connection'
salt.modules.win_ip.set_static_dns(iface, *addrs) Set static DNS configuration on a Windows NIC
• iface (str) -- The name of the interface to set
• addrs -- One or more DNS servers to be added. To clear the list of DNS servers pass an empty list ([]). If undefined or None no changes will be made.
Returns A dictionary containing the new DNS settings
salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.1' salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.252' '192.168.1.253'
salt.modules.win_ip.set_static_ip(iface, addr, gateway=None, append=False) Set static IP configuration on a Windows NIC
iface  The name of the interface to manage
addr   IP address with subnet length (ex. 10.1.2.3/24). The ip.get_subnet_length function can be used to calculate the subnet length from a netmask.
gateway None If specified, the default gateway will be set to this value.
append False If True, this IP address will be added to the interface. Default is False, which overrides any existing configuration for the interface and sets addr as the only address on the interface.
salt -G 'os_family:Windows' ip.set_static_ip 'Local Area Connection' 10.1.2.3/24 gateway=10.1.2.1 salt -G 'os_family:Windows' ip.set_static_ip 'Local Area Connection' 10.1.2.4/24 append=True
salt.modules.win_lgpo Manage Local Policy on Windows
This module allows configuring local group policy (i.e. gpedit.msc) on a Windows server.
Administrative Templates Administrative template policies are dynamically read from ADMX/ADML files on the server.
Windows Settings Policies contained in the "Windows Settings" section of the gpedit.msc GUI are statically defined in this module. Each policy is configured for the section (Machine/User) in the module's _policy_info class. The _policy_info class contains a "policies" dict on how the module will configure the policy, where the policy resides in the GUI (for display purposes), data validation data, data transformation data, etc.
Current known limitations • At this time, start/shutdown scripts policies are displayed, but are not configurable.
• Not all "Security Settings" policies exist in the _policy_info class
• pywin32 Python module
• lxml
• uuid
• struct
salt.modules.win_lgpo.get(policy_class=None, return_full_policy_names=True, hierarchical_return=False, adml_language='en-US', return_not_configured=False) Get a policy value
• policy_class (str) -- Some policies are both user and computer, by default all policies will be pulled, but this can be used to retrieve only a specific policy class User/USER/user = retrieve user policies Machine/MACHINE/machine/Computer/COMPUTER/computer = retrieve machine/computer policies
• return_full_policy_names (bool) -- True/False to return the policy name as it is seen in the gpedit.msc GUI or to only return the policy key/id.
• hierarchical_return (bool) -- True/False to return the policy data in the hierarchy as seen in the gpedit.msc GUI. The default of False will return data split only into User/Computer configuration sections
• adml_language (str) -- The ADML language to use for processing display/descriptive names and enumeration values of ADMX template data, defaults to en-US
• return_not_configured (bool) -- Include Administrative Template policies that are 'Not Configured' in the return data
Returns A dictionary containing the policy values for the specified class
salt '*' lgpo.get machine return_full_policy_names=True
salt.modules.win_lgpo.get_policy(policy_name, policy_class, adml_language='en-US', return_value_only=True, return_full_policy_names=True, hierarchical_return=False) Get the current settings for a single policy on the machine
• policy_name (str) -- The name of the policy to retrieve. Can be the any of the names or alieses returned by lgpo.get_policy_info
• policy_class (str) -- The policy class. Must be one of machine or user
• adml_language (str) -- The language code for the adml file to use for localization. The default is en-US
• return_value_only (bool) -- True will return only the value for the policy, without the name of the policy. return_full_policy_names and hierarchical_return will be ignored. Default is True
• return_full_policy_names (bool) --
Returns the full policy name regardless of what was passed in policy_name
NOTE: This setting applies to sub-elements of the policy if they exist. The value passed in policy_name will always be used as the policy name when this setting is False
• hierarchical_return (bool) -- Returns a hierarchical view of the policy showing its parents
Returns A dictionary containing the policy settings
# Using the policy id salt * lgpo.get_policy LockoutDuration machine salt * lgpo.get_policy AutoUpdateCfg machine
# Using the full name salt * lgpo.get_policy "Account lockout duration" machine salt * lgpo.get_policy "Configure Automatic Updates" machine
# Using full path and name salt * lgpo.get_policy "Windows Components\Windows Update\Configure Automatic Updates" machine
salt.modules.win_lgpo.get_policy_info(policy_name, policy_class, adml_language='en-US') Returns information about a specified policy
• policy_name (str) -- The name of the policy to lookup
• policy_class (str) -- The class of policy, i.e. machine, user, both
• adml_language (str) -- The ADML language to use for Administrative Template data lookup
Returns Information about the specified policy
salt '*' lgpo.get_policy_info 'Maximum password age' machine
You can use lgpo.get_policy_info to get all the possible names that could be used in a state file or from the command line (along with elements that need to be set/etc). The key is to match the text you see in the gpedit.msc gui exactly, including quotes around words or phrases. The "full path" style is really only needed when there are multiple policies that use the same base name. For example, Access data sources across domains exists in ~10 different paths. If you put that through get_policy_info you'll get back a message that it is used for multiple policies and you need to be more specific.
salt-call --local lgpo.get_policy_info ShellRemoveOrderPrints_2 machine
local: ---------- message: policy_aliases: - Turn off the "Order Prints" picture task - ShellRemoveOrderPrints_2 - System\Internet Communication Management\Internet Communication settings\Turn off the "Order Prints" picture task policy_class: machine policy_elements: policy_found: True policy_name: ShellRemoveOrderPrints_2 rights_assignment: False
Escaping can get tricky in cmd/Powershell. The following is an example of escaping in Powershell using backquotes:
PS>salt-call --local lgpo.get_policy_info "Turn off the `\`"Order Prints`\`" picture task" machine
local: ---------- message: policy_aliases: - Turn off the "Order Prints" picture task - ShellRemoveOrderPrints_2 - System\Internet Communication Management\Internet Communication settings\Turn off the "Order Prints" picture task policy_class: machine policy_elements: policy_found: True policy_name: Turn off the "Order Prints" picture task rights_assignment: False
This function can then be used to get the options available for specifying Group Policy Objects to be used in state files. Based on the above any of these should be usable:
internet_communications_settings: lgpo.set: - computer_policy: Turn off the "Order Prints" picture task: Enabled
internet_communications_settings: lgpo.set: - computer_policy: ShellRemoveOrderPrints_2: Enabled
When using the full path, it might be a good idea to use single quotes around the path:
internet_communications_settings: lgpo.set: - computer_policy: 'System\Internet Communication Management\Internet Communication settings\Turn off the "Order Prints" picture task': 'Enabled'
If you struggle to find the policy from get_policy_info using the name as you see in gpedit.msc, the names such as "ShellRemoveOrderPrints_2" come from the .admx files. If you know nothing about .admx/.adml relationships (ADML holds what you see in the GUI, ADMX holds the more technical details), then this may be a little bit too much info, but here is an example with the above policy using Powershell:
PS>Get-ChildItem -Path C:\Windows\PolicyDefinitions -Recurse -Filter *.adml | Select-String "Order Prints"
C:\windows\PolicyDefinitions\en-US\ICM.adml:152:      <string id="ShellRemoveOrderPrints">Turn off the "Order Prints" picture task</string> C:\windows\PolicyDefinitions\en-US\ICM.adml:153:      <string id="ShellRemoveOrderPrints_Help">This policy setting specifies whether the "Order Prints Online" task is available from Picture Tasks in Windows folders. C:\windows\PolicyDefinitions\en-US\ICM.adml:155:The Order Prints Online Wizard is used to download a list of providers and allow users to order prints online. C:\windows\PolicyDefinitions\en-US\ICM.adml:157:If you enable this policy setting, the task "Order Prints Online" is removed from Picture Tasks in File Explorer folders.
From this grep, we can see id "ShellRemoveOrderPrints" is the ID of the string used to describe this policy, then we search for it in the ADMX:
PS>Get-ChildItem -Path C:\Windows\PolicyDefinitions -Recurse -Filter *.admx | Select-String "ShellRemoveOrderPrints"
C:\windows\PolicyDefinitions\ICM.admx:661:    <policy name="ShellRemoveOrderPrints_1" class="User" displayName="$(string.ShellRemoveOrderPrints)" explainText="$(string.ShellRemoveOrderPrints_Help)" key="Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" valueName="NoOnlinePrintsWizard"> C:\windows\PolicyDefinitions\ICM.admx:671:    <policy name="ShellRemoveOrderPrints_2" class="Machine" displayName="$(string.ShellRemoveOrderPrints)" explainText="$(string.ShellRemoveOrderPrints_Help)" key="Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" valueName="NoOnlinePrintsWizard">
Now we have two to pick from. And if you notice the class="Machine" and class="User" (which details if it is a computer policy or user policy respectively) the ShellRemoveOrderPrints_2 is the "short name" we could use to pass through get_policy_info to see what the module itself is expecting.
salt.modules.win_lgpo.set_(computer_policy=None, user_policy=None, cumulative_rights_assignments=True, adml_language='en-US') Set a local server policy.
• computer_policy (dict) --
A dictionary of "policyname: value" pairs of computer policies to set. 'value' should be how it is displayed in the gpedit GUI, i.e.  if a setting can be 'Enabled'/'Disabled', then that should be passed
Administrative Template data may require dicts within dicts, to specify each element of the Administrative Template policy.  Administrative Templates policies are always cumulative.
Policy names can be specified in a number of ways based on the type of policy: Windows Settings Policies: These policies can be specified using the GUI display name or the key name from the _policy_info class in this module.  The GUI display name is also contained in the _policy_info class in this module.
Administrative Template Policies: These can be specified using the policy name as displayed in the GUI (case sensitive). Some policies have the same name, but a different location (for example, "Access data sources across domains"). These can be differentiated by the "path" in the GUI (for example, "Windows ComponentsInternet ExplorerInternet Control PanelSecurity PageInternet ZoneAccess data sources across domains").
Additionally, policies can be specified using the "name" and "id" attributes from the ADMX files.
For Administrative Templates that have policy elements, each element can be specified using the text string as seen in the GUI or using the ID attribute from the ADMX file. Due to the way some of the GUI text is laid out, some policy element names could include descriptive text that appears lbefore the policy element in the GUI.
Use the get_policy_info function for the policy name to view the element ID/names that the module will accept.
• user_policy (dict) -- The same setup as the computer_policy, except with data to configure the local user policy.
• cumulative_rights_assignments (bool) --
Determine how user rights assignment policies are configured.
If True, user right assignment specifications are simply added to the existing policy
If False, only the users specified will get the right (any existing will have the right revoked)
• adml_language (str) -- The language files to use for looking up Administrative Template policy data (i.e. how the policy is displayed in the GUI). Defaults to 'en-US' (U.S. English).
Returns True is successful, otherwise False
salt '*' lgpo.set computer_policy="{'LockoutDuration': 2, 'RestrictAnonymous': 'Enabled', 'AuditProcessTracking': 'Succes, Failure'}"
salt.modules.win_lgpo.set_computer_policy(name, setting, cumulative_rights_assignments=True, adml_language='en-US') Set a single computer policy
• name (str) -- The name of the policy to configure
• setting (str) -- The setting to configure the named policy with
• cumulative_rights_assignments (bool) -- Determine how user rights assignment policies are configured. If True, user right assignment specifications are simply added to the existing policy. If False, only the users specified will get the right (any existing will have the right revoked)
• adml_language (str) -- The language files to use for looking up Administrative Template policy data (i.e. how the policy is displayed in the GUI).  Defaults to 'en-US' (U.S. English).
salt '*' lgpo.set_computer_policy LockoutDuration 1440
salt.modules.win_lgpo.set_user_policy(name, setting, adml_language='en-US') Set a single user policy
Returns True if successful, Otherwise False
salt '*' lgpo.set_user_policy "Control Panel\Display\Disable the Display Control Panel" Enabled
salt.modules.win_license This module allows you to manage windows licensing via slmgr.vbs
salt '*' license.install XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
salt.modules.win_license.activate() Attempt to activate the current machine via Windows Activation
salt '*' license.activate
salt.modules.win_license.info() Return information about the license, if the license is not correctly activated this will return None.
salt '*' license.info
salt.modules.win_license.install(product_key) Install the given product key
salt.modules.win_license.installed(product_key) Check to see if the product key is already installed.
Note: This is not 100% accurate as we can only see the last 5 digits of the license.
salt '*' license.installed XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
salt.modules.win_license.licensed() Return true if the current machine is licensed correctly
salt '*' license.licensed
salt.modules.win_license.uninstall() Uninstall the current product key
salt '*' license.uninstall
salt.modules.win_network Module for gathering and managing network information
salt.modules.win_network.connect(host, port=None, **kwargs) Test connectivity to a host using a particular port from the minion.
salt.modules.win_network.dig(host) Performs a DNS lookup with dig
Note: dig must be installed on the Windows minion
salt.modules.win_network.get_route(ip) Return routing information for given destination ip
New in version 2016.11.5.
salt.modules.win_network.hw_addr(iface) Return the hardware address (a.k.a. MAC address) for a given interface
salt '*' network.hw_addr 'Wireless Connection #1'
salt.modules.win_network.hwaddr(iface) This function is an alias of hw_addr. Return the hardware address (a.k.a. MAC address) for a given interface
salt.modules.win_network.in_subnet(cidr) Returns True if host is within specified subnet, otherwise False
salt.modules.win_network.interfaces() Return a dictionary of information about all the interfaces on the minion
salt.modules.win_network.interfaces_names() Return a list of all the interfaces names
salt '*' network.interfaces_names
salt.modules.win_network.ip_addrs(interface=None, include_loopback=False, cidr=None, type=None) Returns a list of IPv4 addresses assigned to the host.
interface Only IP addresses from that interface will be returned.
include_loopback False Include loopback 127.0.0.1 IPv4 address.
cidr Describes subnet using CIDR notation and only IPv4 addresses that belong to this subnet will be returned.
type   If option set to 'public' then only public addresses will be returned.  Ditto for 'private'.
salt '*' network.ip_addrs salt '*' network.ip_addrs cidr=10.0.0.0/8 salt '*' network.ip_addrs cidr=192.168.0.0/16 type=private
salt.modules.win_network.ip_addrs6(interface=None, include_loopback=False, cidr=None) Returns a list of IPv6 addresses assigned to the host.
include_loopback False Include loopback ::1 IPv6 address.
cidr   Describes subnet using CIDR notation and only IPv6 addresses that belong to this subnet will be returned.
salt '*' network.ip_addrs6 salt '*' network.ip_addrs6 cidr=2000::/3
salt.modules.win_network.ipaddrs(interface=None, include_loopback=False, cidr=None, type=None) This function is an alias of ip_addrs. Returns a list of IPv4 addresses assigned to the host.
salt.modules.win_network.ipaddrs6(interface=None, include_loopback=False, cidr=None) This function is an alias of ip_addrs6. Returns a list of IPv6 addresses assigned to the host.
salt.modules.win_network.is_private(ip_addr) Check if the given IP address is a private address
salt.modules.win_network.netstat() Return information on open ports and states
salt.modules.win_network.nslookup(host) Query DNS for information about a domain or ip address
salt '*' network.nslookup archlinux.org
salt.modules.win_network.ping(host, timeout=False, return_boolean=False) Performs a ping to a host
salt.modules.win_network.subnets() Returns a list of subnets to which the host belongs
salt.modules.win_network.traceroute(host) Performs a traceroute to a 3rd party host
salt.modules.win_ntp Management of NTP servers on Windows
salt.modules.win_ntp.get_servers() Get list of configured NTP servers
salt '*' ntp.get_servers
salt.modules.win_ntp.set_servers(*servers) Set Windows to use a list of NTP servers
salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org'
salt.modules.win_path Manage the Windows System PATH
Note that not all Windows applications will rehash the PATH environment variable, Only the ones that listen to the WM_SETTINGCHANGE message http://support.microsoft.com/kb/104011
salt.modules.win_path.add(path, index=None, **kwargs) Add the directory to the SYSTEM path in the index location. Returns True if successful, otherwise False.
path   Directory to add to path
index  Optionally specify an index at which to insert the directory
rehash True If the registry was updated, and this value is set to True, sends a WM_SETTINGCHANGE broadcast to refresh the environment variables. Set this to False to skip this broadcast.
# Will add to the beginning of the path salt '*' win_path.add 'c:\python27' 0
# Will add to the end of the path salt '*' win_path.add 'c:\python27' index='-1'
salt.modules.win_path.exists(path) Check if the directory is configured in the SYSTEM path Case-insensitive and ignores trailing backslash
Returns boolean True if path exists, False if not
salt '*' win_path.exists 'c:\python27' salt '*' win_path.exists 'c:\python27\' salt '*' win_path.exists 'C:\pyThon27'
salt.modules.win_path.get_path() Returns a list of items in the SYSTEM path
salt '*' win_path.get_path
salt.modules.win_path.rehash() Send a WM_SETTINGCHANGE Broadcast to Windows to refresh the Environment variables for new processes.
NOTE: This will only affect new processes that aren't launched by services. To apply changes to the path to services, the host must be restarted. The salt-minion, if running as a service, will not see changes to the environment until the system is restarted. See MSDN Documentation
salt '*' win_path.rehash
salt.modules.win_path.remove(path, **kwargs) Remove the directory from the SYSTEM path
Returns boolean True if successful, False if unsuccessful
# Will remove C:\Python27 from the path salt '*' win_path.remove 'c:\\python27'
salt.modules.win_pkg A module to manage software on Windows
The following functions require the existence of a windows repository metadata DB, typically created by running pkg.refresh_db:
• pkg.get_repo_data
• pkg.install
• pkg.latest_version
• pkg.list_available
• pkg.list_pkgs
• pkg.list_upgrades
• pkg.remove
If a metadata DB does not already exist and one of these functions is run, then one will be created from the repo SLS files that are present.
As the creation of this metadata can take some time, the winrepo_cache_expire_min minion config option can be used to suppress refreshes when the metadata is less than a given number of seconds old.
NOTE: Version numbers can be version number string, latest and Not Found, where Not Found means this module was not able to determine the version of the software installed, it can also be used as the version number in sls definitions file in these cases. Versions numbers are sorted in order of 0, Not Found, order version numbers, ..., latest.
salt.modules.win_pkg.compare_versions(ver1='', oper='==', ver2='') Compare software package versions. Made public for use with Jinja
• ver1 (str) -- A software version to compare
• oper (str) -- The operand to use to compare
• ver2 (str) -- A software version to compare
Returns True if the comparison is valid, otherwise False
salt '*' pkg.compare_versions 1.2 >= 1.3
salt.modules.win_pkg.genrepo(**kwargs) Generate package metadata db based on files within the winrepo_source_dir
Kwargs: saltenv (str): Salt environment. Default: base
verbose (bool): Return verbose data structure which includes 'success_list', a list of all sls files and the package names contained within.  Default False.
failhard (bool): If True, an error will be raised if any repo SLS files failed to process. If False, no error will be raised, and a dictionary containing the full results will be returned.
• Hidden directories (directories beginning with '.', such as '.git') will be ignored.
Returns A dictionary of the results of the command
salt-run pkg.genrepo salt -G 'os:windows' pkg.genrepo verbose=true failhard=false salt -G 'os:windows' pkg.genrepo saltenv=base
salt.modules.win_pkg.get_package_info(name, saltenv='base') Return package info. Returns empty map if package not available.
salt.modules.win_pkg.get_repo_data(saltenv='base') Returns the existing package metadata db. Will create it, if it does not exist, however will not refresh it.
Parameters saltenv (str) -- Salt environment. Default base
Returns A dict containing contents of metadata db.
salt '*' pkg.get_repo_data
salt.modules.win_pkg.install(name=None, refresh=False, pkgs=None, **kwargs) Install the passed package(s) on the system using winrepo
• name (str) -- The name of a single package, or a comma-separated list of packages to install. (no spaces after the commas)
• refresh (bool) -- Boolean value representing whether or not to refresh the winrepo db.  Default False.
• pkgs (list) --
A list of packages to install from a software repository. All packages listed under pkgs will be installed via a single command.
You can specify a version by passing the item as a dict:
# will install the latest version of foo and bar salt '*' pkg.install pkgs='["foo", "bar"]'
# will install the latest version of foo and version 1.2.3 of bar salt '*' pkg.install pkgs='["foo", {"bar": "1.2.3"}]'
Kwargs:
version (str): The specific version to install. If omitted, the latest version will be installed. Recommend for use when installing a single package.
If passed with a list of packages in the pkgs parameter, the version will be ignored.
# Version is ignored salt '*' pkg.install pkgs="['foo', 'bar']" version=1.2.3
If passed with a comma separated list in the name parameter, the version will apply to all packages in the list.
# Version 1.2.3 will apply to packages foo and bar salt '*' pkg.install foo,bar version=1.2.3
extra_install_flags (str): Additional install flags that will be appended to the install_flags defined in the software definition file. Only applies when single package is passed.
saltenv (str): Salt environment. Default 'base'
report_reboot_exit_codes (bool): If the installer exits with a recognized exit code indicating that a reboot is required, the module function win_system.set_reboot_required_witnessed
will be called, preserving the knowledge of this event for the remainder of the current boot session. For the time being, 3010 is the only recognized exit code. The value of this param defaults to True.
Returns Return a dict containing the new package names and versions. If the package is already installed, an empty dict is returned.
If the package is installed by pkg.install:
The following example will refresh the winrepo and install a single package, 7zip.
salt '*' pkg.install 7zip refresh=True
salt '*' pkg.install 7zip salt '*' pkg.install 7zip,filezilla salt '*' pkg.install pkgs='["7zip","filezilla"]'
WinRepo Definition File Examples:
The following example demonstrates the use of cache_file. This would be used if you have multiple installers in the same directory that use the same install.ini file and you don't want to download the additional installers.
ntp: 4.2.8: installer: 'salt://win/repo/ntp/ntp-4.2.8-win32-setup.exe' full_name: Meinberg NTP Windows Client locale: en_US reboot: False cache_file: 'salt://win/repo/ntp/install.ini' install_flags: '/USEFILE=C:\salt\var\cache\salt\minion\files\base\win\repo\ntp\install.ini' uninstaller: 'NTP/uninst.exe'
The following example demonstrates the use of cache_dir. It assumes a file named install.ini resides in the same directory as the installer.
ntp: 4.2.8: installer: 'salt://win/repo/ntp/ntp-4.2.8-win32-setup.exe' full_name: Meinberg NTP Windows Client locale: en_US reboot: False cache_dir: True install_flags: '/USEFILE=C:\salt\var\cache\salt\minion\files\base\win\repo\ntp\install.ini' uninstaller: 'NTP/uninst.exe'
salt.modules.win_pkg.latest_version(*names, **kwargs) Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned.
NOTE: Since this is looking for the latest version available, a refresh_db will be triggered by default. This can take some time. To avoid this set refresh to False.
Parameters names (str) -- A single or multiple names to lookup
Kwargs: saltenv (str): Salt environment. Default base refresh (bool): Refresh package metadata. Default True
Returns A dictionary of packages with the latest version available
salt.modules.win_pkg.list_available(*names, **kwargs) Return a list of available versions of the specified package.
Parameters names (str) -- One or more package names
Kwargs: saltenv (str): The salt environment to use. Default base.
refresh (bool): Refresh package metadata. Default False.
return_dict_always (bool): Default False dict when a single package name is queried.
Returns The package name with its available versions
{'<package name>': ['<version>', '<version>', ]}
salt '*' pkg.list_available <package name> return_dict_always=True salt '*' pkg.list_available <package name01> <package name02>
salt.modules.win_pkg.list_pkgs(versions_as_list=False, include_components=True, include_updates=True, **kwargs) List the packages currently installed.
NOTE: To view installed software as displayed in the Add/Remove Programs, set include_components and include_updates to False.
• versions_as_list (bool) -- Returns the versions as a list
• include_components (bool) -- Include sub components of installed software. Default is True
• include_updates (bool) -- Include software updates and Windows updates. Default is True
saltenv (str): The salt environment to use. Default base
refresh (bool): Refresh package metadata. Default False
Returns A dictionary of installed software with versions installed
salt.modules.win_pkg.list_upgrades(refresh=True, **kwargs) List all available package upgrades on this system
Parameters refresh (bool) -- Refresh package metadata. Default True
Kwargs: saltenv (str): Salt environment. Default base
Returns A dictionary of packages with available upgrades
salt.modules.win_pkg.purge(name=None, pkgs=None, **kwargs) Package purges are not supported on Windows, this function is identical to remove().
NOTE: At some point in the future, pkg.purge may direct the installer to remove all configs and settings for software packages that support that option.
• name (str) -- The name of the package to be deleted.
• version (str) -- The version of the package to be deleted. If this option is used in combination with the pkgs option below, then this version will be applied to all targeted packages.
• pkgs (list) -- A list of packages to delete. Must be passed as a python list. The name parameter will be ignored if this option is passed.
Kwargs: saltenv (str): Salt environment. Default base refresh (bool): Refresh package metadata. Default False
Returns A dict containing the changes.
salt.modules.win_pkg.refresh_db(**kwargs) Generates the local software metadata database (winrepo.p) on the minion.  The database is stored in a serialized format located by default at the following location:
C:\salt\var\cache\salt\minion\files\base\win\repo-ng\winrepo.p
This module performs the following steps to generate the software metadata database:
• Fetch the package definition files (.sls) from winrepo_source_dir (default salt://win/repo-ng) and cache them in <cachedir>files<saltenv><winrepo_source_dir> (default: C:\salt\var\cache\salt\minion\files\base\win\repo-ng)
• Call pkg.genrepo to parse the package definition files and generate the repository metadata database file (winrepo.p)
• Return the report received from pkg.genrepo
The default winrepo directory on the master is /srv/salt/win/repo-ng. All files that end with .sls in this and all subdirectories will be used to generate the repository metadata database (winrepo.p).
NOTE: There is no need to call pkg.refresh_db every time you work with the pkg module. Automatic refresh will occur based on the following minion configuration settings:
• winrepo_cache_expire_min
• winrepo_cache_expire_max
However, if the package definition files have changed, as would be the case if you are developing a new package definition, this function should be called to ensure the minion has the latest information about packages available to it.
WARNING: Directories and files fetched from <winrepo_source_dir> (/srv/salt/win/repo-ng) will be processed in alphabetical order. If two or more software definition files contain the same name, the last one processed replaces all data from the files processed before it.
For more information see Windows Software Repository
saltenv (str): Salt environment. Default: base
verbose (bool): Return a verbose data structure which includes 'success_list', a list of all sls files and the package names contained within.  Default is 'False'
failhard (bool): If True, an error will be raised if any repo SLS files fails to process. If False, no error will be raised, and a dictionary containing the full results will be returned.
Returns A dictionary containing the results of the database refresh.
NOTE: A result with a total: 0 generally means that the files are in the wrong location on the master. Try running the following command on the minion: salt-call -l debug pkg.refresh saltenv=base
WARNING: When calling this command from a state using module.run be sure to pass failhard: False. Otherwise the state will report failure if it encounters a bad software definition file.
salt '*' pkg.refresh_db salt '*' pkg.refresh_db saltenv=base
salt.modules.win_pkg.remove(name=None, pkgs=None, **kwargs) Remove the passed package(s) from the system using winrepo
• name (str) -- The name(s) of the package(s) to be uninstalled. Can be a single package or a comma delimited list of packages, no spaces.
version (str): The version of the package to be uninstalled. If this option is used to to uninstall multiple packages, then this version will be applied to all targeted packages. Recommended using only when uninstalling a single package. If this parameter is omitted, the latest version will be uninstalled.
saltenv (str): Salt environment. Default base refresh (bool): Refresh package metadata. Default False
Returns Returns a dict containing the changes.
If the package is removed by pkg.remove:
If the package is already uninstalled: {'<package>': {'current': 'not installed'}}
salt.modules.win_pkg.upgrade(**kwargs) Upgrade all software. Currently not implemented
Kwargs: saltenv (str): The salt environment to use. Default base. refresh (bool): Refresh package metadata. Default True.
NOTE: This feature is not yet implemented for Windows.
Returns Empty dict, until implemented
salt.modules.win_pkg.upgrade_available(name, **kwargs) Check whether or not an upgrade is available for a given package
Parameters name (str) -- The name of a single package
Kwargs: refresh (bool): Refresh package metadata. Default True saltenv (str): The salt environment. Default base
Returns True if new version available, otherwise False
salt.modules.win_pkg.version(*names, **kwargs) Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned.
Parameters name (str) -- One or more package names
Kwargs: saltenv (str): The salt environment to use. Default base. refresh (bool): Refresh package metadata. Default False.
Returns version string when a single package is specified.  dict: The package name(s) with the installed versions.
{['<version>', '<version>', ]} OR {'<package name>': ['<version>', '<version>', ]}
salt '*' pkg.version <package name> salt '*' pkg.version <package name01> <package name02>
salt.modules.win_pki Microsoft certificate management via the PKI Client PowerShell module. https://technet.microsoft.com/en-us/itpro/powershell/windows/pkiclient/pkiclient
The PKI Client PowerShell module is only available on Windows 8+ and Windows Server 2012+. https://technet.microsoft.com/en-us/library/hh848636(v=wps.620).aspx
• PowerShell 4
• PKI Client Module (Windows 8+ / Windows Server 2012+)
salt.modules.win_pki.export_cert(name, thumbprint, cert_format='cer', context='LocalMachine', store='My', password='') Export the certificate to a file from the given certificate store.
• name (str) -- The destination path for the exported certificate file.
• thumbprint (str) -- The thumbprint value of the target certificate.
• cert_format (str) -- The certificate format. Specify 'cer' for X.509, or 'pfx' for PKCS #12.
• context (str) -- The name of the certificate store location context.
• store (str) -- The name of the certificate store.
• password (str) -- The password of the certificate. Only applicable to pfx format. Note that if used interactively, the password will be seen by all minions. To protect the password, use a state and get the password from pillar.
salt '*' win_pki.export_cert name='C:\certs\example.cer' thumbprint='AAA000'
salt.modules.win_pki.get_cert_file(name, cert_format='cer', password='') Get the details of the certificate file.
• name (str) -- The filesystem path of the certificate file.
Returns A dictionary of the certificate thumbprints and properties.
salt '*' win_pki.get_cert_file name='C:\certs\example.cer'
salt.modules.win_pki.get_certs(context='LocalMachine', store='My') Get the available certificates in the given store.
salt '*' win_pki.get_certs
salt.modules.win_pki.get_stores() Get the certificate location contexts and their corresponding stores.
Returns A dictionary of the certificate location contexts and stores.
salt '*' win_pki.get_stores
salt.modules.win_pki.import_cert(name, cert_format='cer', context='LocalMachine', store='My', exportable=True, password='', saltenv='base') Import the certificate file into the given certificate store.
• name (str) -- The path of the certificate file to import.
• exportable (bool) -- Mark the certificate as exportable. Only applicable to pfx format.
salt '*' win_pki.import_cert name='salt://cert.cer'
salt.modules.win_pki.remove_cert(thumbprint, context='LocalMachine', store='My') Remove the certificate from the given certificate store.
salt '*' win_pki.remove_cert thumbprint='AAA000'
salt.modules.win_pki.test_cert(thumbprint, context='LocalMachine', store='My', untrusted_root=False, dns_name='', eku='') Check the certificate for validity.
• untrusted_root (bool) -- Whether the root certificate is required to be trusted in chain building.
• dns_name (str) -- The DNS name to verify as valid for the certificate.
• eku (str) -- The enhanced key usage object identifiers to verify for the certificate chain.
Returns A boolean representing whether the certificate was considered valid.