[updated: 1/14/19] Changed project from GitLab to GitHub and added some newly updated cmdlets.
I've written a small pet project called KaceSMA, a light weight SMA Powershell module that you can install on Windows,Mac,or Linux (mac/linux via PSCore). What it does is it essentially wraps the API in a Powershell compatibility layer and returns objects in a easy to digest format for all your automation needs. How do you use it you ask?
[edit] Updated way to install:
From a PS shell:
Install-Module KaceSMA
Here is the project: https://github.com/ArtisanByteCrafter/KaceSMA
Here's some basic examples of what you can do, along with the code to do it:
https://github.com/ArtisanByteCrafter/KaceSMA/wiki
- Invoke a script against a list of machines
- Add a task to an existing script
- Return Machines with Encryption status of "Fully Encrypted"
- Return SMA inventory machines with title 'Arduino' installed
- Return all inventory members of smart label named "D - SmartLabel - Test"
- Find the registry uninstall strings of all Software Inventory VMWare products
The only limit is really your API parameter creativity.
I expose the following Functions for use (today). More are being added often.
(Get-Command -Module KaceSMA).name
Get-SmaAgentlessInventory Get-SmaArchiveAsset Get-SmaAsset Get-SmaAssetType Get-SmaBarcodeAsset Get-SmaCurrentUserAccount Get-SmaMachineInventory Get-SmaMachineProcess Get-SmaMachineService Get-SmaManagedInstall Get-SmaManagedInstallMachineCompatibility Get-SmaOperatingSystemInventory Get-SmaReportingDefinition Get-SmaScript Get-SmaScriptDependency Get-SmaScriptRunStatus Get-SmaScriptTask Get-SmaServiceDeskQueue Get-SmaServiceDeskQueueField Get-SmaServiceDeskTicket Get-SmaServiceDeskTicketTemplate Get-SmaSoftwareInventory Get-SmaStartupProgramInventory Get-SmaUserPermissions Invoke-SmaScript New-SmaAsset New-SmaScript New-SmaScriptTask New-SmaServiceDeskTicket Remove-SmaServiceDeskTicket Set-SmaAssetAsArchived Set-SmaMachineInventory Set-SmaServiceDeskTicket
This isn't an exhaustive list of the API, there are a few I'm not exposing yet due to bugs on the SMA API end (dutifully ticketed and tracked already via support request with Quest), namely the Managed Install endpoint. If anyone has a request for a GET method that isn't covered, let me know- or submit a Pull Request!
You can install via "Install-Module KaceSMA", and update with "Update-Module KaceSMA". You can also clone the repository if you'd rather.
Here's an output if a simple asset retrieval:
Thanks, and happy coding!
Nathaniel Webb (isudothings)
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy - M1st3rS1r 6 years ago
One issue i'm having that perhaps i'm missing something simple is that when i attempt to use Get-SmaAsset or Get-SmaMachineInventory, it shows the proper count, but the details are limited to only 50 machines. How can i get all assets or inventory items? - dwestness 5 years ago
Could you help me with an error I'm getting though?
I am able to connect and get information from KACE SMA, but when I try to invoke or get a script I get a "Invoke-RestMethod : The remote server returned an error: (403) Forbidden." error. When I go the {KaceServer}/api the webpage says "{"error": "API disabled."}"
Do you know what's causing this and how to fix it? - JKith 1 year ago