< Back

Add-GlpiToolsItems

Mon Jan 13, 2020 9:06 pm

NAME Add-GlpiToolsItems



SYNOPSIS

Function Add an object (or multiple objects) into GLPI.





SYNTAX

Add-GlpiToolsItems -AddTo <String> -HashtableToAdd <Hashtable> [<CommonParameters>]



Add-GlpiToolsItems -AddTo <String> [-JsonPayload <Array>] [<CommonParameters>]





DESCRIPTION

Function Add an object (or multiple objects) into GLPI. You can choose between every items in Asset Tab.





PARAMETERS

-AddTo <String>

Parameter specify where you want to add new object.

You can add your custom parameter options to Parameters.json file located in Private folder



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-HashtableToAdd <Hashtable>

Parameter specify a hashtable with fields of itemtype to be inserted.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-JsonPayload <Array>

Parameter specify a hashtable with "input" parameter to be a JsonPayload.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

Hashtable with "input" parameter, or JsonPayload .





OUTPUTS

Information with id and message, which items were added.





NOTES





PSP 04/2019



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-GlpiToolsItems -AddTo Computer -HashtableToAdd @{name = "test"} | ConvertTo-Json



Example will add item into Computers









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$example = @{name = "test"} | ConvertTo-Json



PS C:\\> Add-GlpiToolsItems -AddTo Computer -HashtableToAdd $example

Example will add item into Computers









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>$example = @{ name = "test" } | ConvertTo-Json



PS C:\\> $upload = '{ "input" : ' + $example + '}'

PS C:\\> Add-GlpiToolsItems -AddTo Computer -JsonPayload $upload









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$example = "@



{

"input" : [

{

"name" : "test1",

"comment" : "updated from script"

},

{

"name" : "test2",

"comment" : "updated from script"

}

]

}

@"

PS C:\\> Add-GlpiToolsItems -AddTo Computer -JsonPayload $example

Example will Add items into Computers











RELATED LINKS