Coder Social home page Coder Social logo

itop-jb-powershell's Introduction

PSM1 iTop module for PowerShell

Copyright (C) 2019-2024 Jeffrey Bostoen

License Donate ๐Ÿป โ˜•

Need assistance with iTop or one of its extensions?
Need custom development?
Please get in touch to discuss the terms: [email protected] / https://jeffreybostoen.be

What?

A PowerShell module for iTop by Combodo.
Written to automate some tasks which are repeated a lot in development and production environments.

Trivia: this is my very first PowerShell module ever.

Documentation

itop-jb-powershell's People

Contributors

jbostoen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

itop-jb-powershell's Issues

Create computer with new document attached?

When creating a new computer with a new document, should I:

  1. Pass document parameters in the hashtable of "-Fields" attribute of New-iTopObject command? Like this:
$parametrs_PC = @{
    'name' = $ComputerName
    'org_id' = 3 
    'location_id' = 1 
    'brand_id' = 29 
    'model_id' = 330 
    'osfamily_id' = 4 
    'osversion_id' = 328 
    'type' = 'laptop'
    'cpu' = 'Intel Core i5-11300H'
    'ram' = '8GB'
    'serialnumber' = 'numerseryjny'
    'asset_number' = 'AB-xxx'
    'move2production' = '2021-12-14'
    'purchase_date' = '2021-11-18'
    'end_of_warranty' = '2024-11-18'
    'contacts_list' = @(@{'contact_id'=344})
    **'documents_list' = @(@{'name'=$ComputerName })**
}
  1. Create a document first and THEN attach it to a computer?

The first method returns an error:

iTop API returned an error: 100 - Error: documents_list: name: Unknown attribute

How to connect to API/RESTful with Powershell

Hi there,

I'ld like to connect to the API of iTop via Powershell to execute some maintenance tasks.

Therefore I downloaded the Powershell Module, extract it to my Powershell Module directory in C:\Program Files\WindowsPowerShell\Modules and created a .json file like it is mentioned in the documentation for iTop called production.json.
This file is located in C:\Program Files\WindowsPowerShell\Modules\iTop.Environments\environments
But when I try to execute a command it will only prompt an error

image

I also created it in C:\Users%username%\Documents\WindowsPowerShell\Modules\iTop\environments

Content of production.json
`{

// Note: It is not necessary to include or adjust all settings below.
// For example, if you're only interested in using the API, the "API" block is already enough.

// If this mostly inherits settings from another configuration file, you can specify the name of that configuration here.
// It allows you to for example have one common configuration file, with very few adjustments.
"InheritFrom": "someOtherEnvironmentName",

// Variables can be used at any time. They are placeholders that are defined here.
// For example, here a variable 'Environment' (can be anything, as long as it's a valid JSON property name) is configured and its value is set to 'production'.
// In other settings, whenever %Environment% is used somewhere, it will be replaced with 'production'.
"Variables": {
	"Environment": "production",
},
	
// This section below is only relevant when using the iTop.API PowerShell module.

	// More info: https://www.itophub.io/wiki/page?id=latest:advancedtopics:rest_json
	"API": {
		// The iTop REST/JSON API endpoint URL.
		// Explicitly add the login mode.
		// Currently supports:
		// login_mode=url (URL parameters such as auth_user and auth_pwd will be added)
		// login_mode=basic (HTTP Basic Authentication will be used)
		// login_mode=token (iTop application token will be used)
		
        "Url":  "http://10.131.4.36/webservices/rest.php?login_mode=url",
		// Version of the iTop API.
		"Version":  "1.3",
		// Username and password for the iTop API user.
		// Mind that for now, the module uses the configured URL to determine how to authenticate.
		"User":  "api",
		"Password":  "<<password>>",
		// Or alternatively, use an application token:
		"Token": "iTopApplicationToken",
		// Specify the default output. '*' means all attributes of the queried class, '*+' means all attributes of the object's class.
		// For example, if tickets are queried, '*' would return all the attributes which are defined for the ticket class.
		// However, tickets could include changes, incidents, user requests, ... . Those classes each have some unique attributes. '*+' would expose those attributes in the result.
		"Output_Fields":  "*"
	},

// This section below is only relevant when you want to use the iTop.Local PowerShell module 
// to interact with an iTop environment on the local machine.


	// This is used when using the an unattended installation or upgrade, 
	// or when performing certain tweaks (e.g. Remove-iTopLanguage).
	"App":  {
	
		// Local path to an iTop installation.
		"Path":  "C:\\xampp\\htdocs\\iTop\\web",
		
		// Name of the iTop environment. For 99% of the use cases, this will be "production".
		// Only when working with different iTop environment names, this needs to be adjusted.
		"Environment":  "%Environment%",
	
		// Only relevant for unattended install of iTop.
		// More info: https://www.itophub.io/wiki/page?id=latest:advancedtopics:automatic_install
		"UnattendedInstall": {
			// This setting points to the location where the PHP script is found to execute an unattended installation.
			"Script":  "C:\\xampp\\htdocs\\iTop\\web\\toolkit\\unattended_install.php", 
			// These settings point to the unattended XML file.
			"InstallXML":  "C:\\xampp\\htdocs\\iTop\\web\\toolkit\\unattended_install.xml",
			"UpgradeXML":  "C:\\xampp\\htdocs\\iTop\\web\\toolkit\\unattended_upgrade.xml",
		},
		
		// The short code of the language files that should be kept by default.
		// For example, use "en" for English. Check the iTop language files to discover all prefixes.
		"Languages": [
			"en",
			"de",
			"fr",
			"nl"
		] 
	},
	
	// Cron settings.
	// If you're planning to execute the cron background process from the command line (Start-iTopCron),
	// the iTop user credentials must be provided here.
	"Cron": {
		"User": "admin",
		"Password": "admin"
	},
	
	// Extension settings.
	// This is meant to ease local development.
	// The settings are used when creating or renaming extensions; or to quickly set common publisher info.
	"Extensions": {
	   "Path":  "C:\\xampp\\htdocs\\iTop\\web\\extensions", 
	   "Url":  "https://jeffreybostoen.be",
	   "VersionMin":  "2.7.0", 
	   "VersionDataModel":  "1.7", 
	   "Author":  "Jeffrey Bostoen", 
	   "Company":  "Jeffrey Bostoen", 
	   "VersionDescription":  "" 
	},
	
	"PHP": {
		"Path": "C:\\xampp\\php\\php.exe"
	}

}
`

Thanks Shorty

Question with TeemIP

Hello,
just a question, i would like to know it your powershell module can work with TeemIp extension ?
i would like to have IP address and DNS name management with powershell

Thanks !

Create a computer with a contact?

Is it possible to create a computer with a contact person? This is my fields parameter:

$parametry_PC = @{
    'name' = $ComputerName
    'org_id' = 3 
    'location_id' = 1 
    'brand_id' = 29 
    'model_id' = 330 
    'osfamily_id' = 4 
    'osversion_id' = 328 
    'type' = 'laptop'
    'cpu' = 'Intel Core i5-11300H'
    'ram' = '8GB'
    'serialnumber' = 'numerseryjny'
    'asset_number' = 'AS-xxx'
    'move2production' = '2021-12-14'
    'purchase_date' = '2021-11-18'
    'end_of_warranty' = '2024-11-18'
    'contacts_list' = @{'contact_id'=344
                        'contact_name' = 'Doe'
                        }
}

Everything works except the contacts_list parameter. I get the following error:

iTop API returned an error: 100 - Error: contacts_list: A link set must be defined by an array of objects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.