Hi, I have managed to use the webservices for ITAM using powershell.
(if you change in the script below the operator to equal and the pcname0% to the exact PCname, it will find your record)
However, now I am trying to search for a partial name, I am expecting to see multiple records to be returned:
$URL = "C:\itam\DEV\ITAM0.wsdl"
$usd = New-WebServiceProxy -uri $URL
$iSID = $usd.login("username","password")
if ($? -eq $False)
{
write-host "Failed to connect to USD environment so stopping script"
exit
}
$asset = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.asset
$sd = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.SearchDefinition
$sdcriteria=new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.Criteria
$sdcriterion=new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.Criterion
$asset.assetname = "pcname0%"
$sdcriterion.Operator = "Like"
$sdcriterion.SearchObjects = $asset
$sdcriteria.CriteriaList = $sdcriterion
$sd.Criteria = $sdcriteria
$AssetResult = $usd.search($sd)
foreach ($pc in $AssetResult)
{
$pc
}
$usd.logout()
I can also update the asset and then push the update to ITAM, so making progress
but you see the example above already, I am trying to use the operator "like" (it is accepted - match or contains throws an error) but it never returns any data while I know it should return 2 records when it search from the console....
but the documentation is painfully limited... I have 4 examples and ITAM shows 4 examples but just one search, one create, one delete and one update. and the search is using the equal option....
I would like to be able to use wildcards, it will be especially useful when searching for things like Operating System, or vendor etc...
I do get an error - which then shows valid operators:
Specify one of the following enumerator names and try again: Equal, NotEqual, Like, NotLike, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, Between, NotBetween, In, NotIn, IsNull, IsNotNull, None
so Like is a proper operator...
any suggestions are welcome