Loading
Requesting Computer Name
Hello. I have a rather complicated issue and question but everyone was so helpful with my last question I'm hopeful. My companies Active Directory tree is sort of a mess some of it caused by design and other by acquisition. We have multiple trees joined by trusts and a few trees with little or no connection as they are isolated secure environments. We originally tried to use the Reverse DNS look up to find the Requesting Computer Name but quickly realized that when requesting for machines in other AD trees the reverse DNS would not work. We are able to deploy software to the other environments by utilizing SCCM connection to those trees. We had Snow create a Powershell Web Service to query SLM for the computer names associated with the users as we have Gateway servers placed in the other AD environments feeding discovery information to SLM. The Powershell works fairly well but it requires that the end user know the domain they are requesting the software in. This is not the ideal state but really causes issues for the Apple machines as they appear as if they are local accounts in SLM so the user would have to populate the machine name\userid. I would like to resolve this issue and make the user experience better for the non Apple users by figuring out away to not require the domain. Is there away to use a wildcard in the API call (Ex: %\userid). Below is the Powershell were using.  Thanks!!! Jerry function SLM_Computers   {   param($slmuser) $apiAccountName = Get-APSetting "SLMApiAccountName"   $SLMServerName = Get-APSetting "SLMServerName"   $SLMCustomerId = Get-APSetting "CustomerId"     $apiUserAccount = Get-ServiceAccount -Name "$apiAccountName" -Scope 1   $securePassword = ConvertTo-SecureString $($apiUserAccount.Password) -AsPlainText -Force   $credential = New-Object Management.Automation.PSCredential ($($apiUserAccount.AccountName), $securePassword)   $user = "***"   $version = 8   $secpasswd = ConvertTo-SecureString “***” -AsPlainText -Force   $customer = "1"   $SLMServerName = "****"   $credential = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)   #$username = "centene\jyarbrough"   #$slmuser= $username function GetAPIFilterUri { Param([string]$username) return " http:// " + $SLMServerName + "/api/customers/1/users/?`$filter=Username%20eq%20%27"+ $username + "%27&`$top=1&`$format=json"   } function GetUserByUserNameWithFilter{   Param([string]$username) $body = Invoke-RestMethod -Uri (GetAPIFilterUri -username $username) -Method Get -Credential $credential $u = $body.Body return $u.Body   } function GetUserByUserName{   Param([string]$username) $body = Invoke-RestMethod -Uri $slmhost -Method Get -Credential $credential $u = $body.Body | ? {$_.Body.Username -like "*$username*"} return $u.Body   }     function GetUserByUserNameLinkComputers {   Param([string]$userid) $url = " http:// " + $SLMServerName + "/api/customers/1/users/" + $userid + "/?`$format=json"   $body = Invoke-RestMethod -Uri $url -Method Get -Credential $credential return ($body.Links | ? {$_.Rel -like "*Computers*"})   } $un = "$slmuser" $user = GetUserByUserNameWithFilter -username $un $usercomplinks = GetUserByUserNameLinkComputers -userid $user[0].Id.ToString()   function GetComputersFromUserLink{   Param([string]$compurl) $body = Invoke-RestMethod -Uri $compurl -Method Get -Credential $credential return $body.Body   }   function GetListOfComputerNamesFromUserUrl {   Param([string]$url) $complist = @() $comps = GetComputersFromUserLink -compurl $usercomplinks.Href $justcomps = $comps| ? {$_.Body.OperatingSystem -notlike "*server*"}     #echo $justcomps.Body ForEach($comp in $justcomps) {   [string]$n= $comp.Body.Name $n   }   return $complist   } $cl = GetListOfComputerNamesFromUserUrl   $cl   }

  • Oskar Frolin (Flexera Software)

    Hi Jerry, I can't confirm right now but you could possibly do a "like" or similar in the SLM filtered api query (.....ilter=Username%20eq%20%27".... -> ....ilter=Username%20like%20%27"....). If you browse the SLM API to that endpoint you should get some help on editing that query. But another "solution" would be if you had for example every user as manager or any other ad attribute in Active Directory, and did a direct check to that value. This would be a "simpler" technical solution, but would require you to feed that data into AD if it's not already there. /Oskar
    Expand Post
    • Hi Oskar, The like doesn't appear to be working unless I have something configured incorrectly. I checked the API help but didn't see anything about wild card queries.  Thanks! Jerry
      • Oskar Frolin (Flexera Software)

        Hi Jerry, I had time to check now and you could probably do a "endwith" filter. Look at the screenshot below from one of our demo environment, with nice arrows  I checked the Help-HowToQuery to find the functions. Note that there was a looot more functions here than i expected In my example i just filter on all usernames ending with 1, you should be able to filter on all usernames ending with your PS variable $username instead to get the result you need. return " http:// " + $SLMServerName + "/api/customers/1/users/?`$filter=Username%20eq%20%27"+ $username + "%27&`$top=1&`$format=json"   return " http:// " + $SLMServerName + "/api/customers/1/users/?`$filter=endswith%28Username%2C%27" + $username + "%27%29&`$top=1&`$format=json" //Oskar
        Expand Post

Related  Product Forums


                     → Flexera One



                      → Snow Atlas



                      → FlexNet Manager



                      → Snow License Manager



                       → App Broker


       Need help finding an answer?


        Ask a Question →


Loading
Requesting Computer Name