---
updatedAt: 2025-08-14T17:15:42.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Device Asset Report from API

```powershell PowerShell
Clear-Host
Clear

#
# Determine where the N-Central server is
# Uncomment this next line if you want the N-central URL to be a command line parameter

#
##### Input 1 ---------------------------------------------------------------------------
#

# $serverHost = Read-Host "Enter the fqdn of the N-Central Server "
# $serverHost = "n-central.domain.com"
 $serverHost = Read-Host "Enter N-Central URL [server.domain.com] "

#
# Generate a pseudo-unique namespace to use with the New-WebServiceProxy and 
# associated types.
#
# By controlling the namespace, the script becomes portable and is not
# dependent upon the endpoint url the webservice is connecting.  However, this
# introduces another complexity because once the namespace is defined within a
# powershell session, it cannot be reused, nor can it be undefined.  As long as
# all the calls are made to the existing webserviceproxy, then everything would be
# OK. But, if you try to rerun the script without closing and reopening the
# powershell session, you will get an error.
#
# One way around this is to create a unique namespace each time the script is run.
# We do this by using the last 'word' of a GUID appended to our base namespace 'NAble'.
# This means our type names for parameters (such as T_KeyPair) now have a dynamic
# type.  We could pass types to each new-object call using "$NWSNameSpace.T_KeyPair",
# and I find it more readable to define our 'dynamic' types here and use the typenames
# in variables when calling New-Object.
#
$NWSNameSpace = "NAble" + ([guid]::NewGuid()).ToString().Substring(25)
$KeyPairType = "$NWSNameSpace.T_KeyPair"
$KeyValueType = "$NWSNameSpace.T_KeyValue"


#
# Create DeviceData and DeviceIdentifiers data types to hold info
#
Add-Type -TypeDefinition @"
public class DeviceIdentifiers {
	public string ID;
	}
"@

#
# Defining the output columns in the CSV file
# 

Add-Type -TypeDefinition @"
public class DeviceData {
	public string Customer;
	public string Name;
	public string NETBIOS;
	public string DeviceID;
    public string DeviceClass;
	public string DeviceAdded;
	public string IPAddress;
    public string Gateway;
    public string DNS;
	public string DHCP;
	public string DeviceBoot;
	public string Model;
    public string Manufacturer;
    public string SerialNumber;
    public string OS;
	public string OSARCH;
	public string OSversion;
	public string OSCSDversion;
    public string Processor;
    public string TotalPhysicalMemory;
    public string HardDriveCapacity;
    public string WarrantyExpiryDate;
	public string PopMemorySlots;
	public string TotalMemorySlots;
	
    
	}
"@


#
# Get credentials
# We could read them as plain text and then create a SecureString from it
# By reading it as a SecureString, the password is obscured on entry
#
# We still have to extract a plain-text version of the password to pass to
# the API call.
# Uncomment this next line if you want the N-central User Account to be a command line parameter

#
##### Input 2 ----------------------------------------------------------------------------------
#

$username = Read-Host "Enter N-Central user id "
#$username = "api@domain.com"
$secpasswd = Read-Host "Enter Password" -AsSecureString

$creds = New-Object System.Management.Automation.PSCredential ("\$username", $secpasswd)
$password = $creds.GetNetworkCredential().Password



$bindingURL = "http://" + $serverHost + "/dms2/services2/ServerEI?wsdl"
$nws = New-Webserviceproxy $bindingURL -credential $creds -Namespace ($NWSNameSpace)



#
# Select the output file
#
Write-Host
# Uncomment the line below and the final line of the script to get output in a CSV file
# $CSVFile = (Read-Host "Enter the CSV output filename ").Trim()

#
# Set up and execute the query
#
$1stKeyPairs = @()
$1stKeyPair = New-Object -TypeName $KeyPairType
$1stKeyPair.Key = 'customerID'

#
##### Input 3 ------------------------------------------------------------------------------------
#

# Enter the Customer ID for the customer you want to query in the line below
# Get the Customer ID from the N-central UI
# 	Select Service Organization > Administration > Customers
# To query all customers, use the Service Organization ID
# 	Select System > Administration > Service Organizations
# If you are using a hosted N-central server, the Support Team can assist you with this ID
# $1stKeyPair.Value = "100"
$1stKeyPair.Value = Read-Host "Enter N-Central customer id "
$1stKeyPairs += $1stKeyPair

$DeviceIDQuery = $nws.deviceList($username, $password, $1stKeyPairs)


#
# Set up the devices array, then populate
#
$DeviceIDs = @()

foreach ($ID in $DeviceIDQuery) {
	$DeviceList = @{}
	foreach ($item in $ID.Info) {$DeviceList[$item.key] = $item.Value}

	$DeviceID = New-Object DeviceIdentifiers
	$DeviceID.ID = $DeviceLIst["device.deviceid"]
	
	$Script:DeviceIDs += $DeviceID

	Remove-Variable DeviceList
	}



#-- Reduce amount of data returned by filtering
 $optionalSettings = @()

 # Filter by DeviceID numbers
 $optionalSetting = New-Object -TypeName $KeyValueType
 $optionalSetting.Key = "TargetByDeviceID"
 $optionalSetting.Value = $DeviceIDs | select -expand ID # Replace with some real ID numbers
 $optionalSettings += $optionalSetting

 
 # Additional filtering by information category
 $optionalSetting = New-Object -TypeName $KeyValueType
 $optionalSetting.Key = "InformationCategoriesInclusion"
 $optionalSetting.Value = @("asset.device", "asset.computersystem", "asset.os", "asset.processor", "asset.logicaldevice", "asset.networkadapter", "asset.customer")
 $optionalSettings += $optionalSetting

 $DeviceAssetInfo = $nws.DeviceAssetInfoExport2("0.0", $username, $password, $optionalSettings)


$Devices = @()

foreach ($DeviceEntry in $DeviceAssetInfo) {
    $DeviceAssetInfo = @{}
	foreach ($item in $DeviceEntry.Info) {$DeviceAssetInfo[$item.key] = $item.Value}

	$Device = New-Object DeviceData
	$Device.Name = $DeviceAssetInfo["asset.device.longname"]
	$Device.NETBIOS = $DeviceAssetInfo["asset.computersystem.netbiosname"]
    $Device.DeviceID = $DeviceAssetInfo["asset.device.deviceid"]
	$Device.DeviceClass = $DeviceAssetInfo["asset.device.deviceclass"]
	$Device.DeviceAdded = $DeviceAssetInfo["asset.device.createdon"]
	$Device.DeviceBoot = $DeviceAssetInfo["asset.os.lastbootuptime"]
    $Device.Model = $DeviceAssetInfo["asset.computersystem.model"]
    $Device.Manufacturer = $DeviceAssetInfo["asset.computersystem.manufacturer"]
    $Device.SerialNumber = $DeviceAssetInfo["asset.computersystem.serialnumber"]
    $Device.OS = $DeviceAssetInfo["asset.os.reportedos"]
	$Device.OSARCH = $DeviceAssetInfo["asset.os.osarchitecture"]
	$Device.OSversion = $DeviceAssetInfo["asset.os.version"]
	$Device.OSCSDversion = $DeviceAssetInfo["asset.os.csdversion"]
    $Device.Processor = $DeviceAssetInfo["asset.processor.name"]
    $Device.TotalPhysicalMemory = $DeviceAssetInfo["asset.computersystem.totalphysicalmemory"] / 1073741824
	$Device.PopMemorySlots = $DeviceAssetInfo["asset.computersystem.populatedmemory_slots"]
	$Device.TotalMemorySlots = $DeviceAssetInfo["asset.computersystem.totalmemory_slots"]
    $Device.HardDriveCapacity = $DeviceAssetInfo["asset.logicaldevice.maxcapacity.0"] / 1073741824
    $Device.IPAddress = $DeviceAssetInfo["asset.networkadapter.ipaddress.0"]
    $Device.Gateway = $DeviceAssetInfo["asset.networkadapater.gateway.0"]
    $Device.DNS = $DeviceAssetInfo["asset.networkadapter.dnsserver.0"]
	$Device.DHCP = $DeviceAssetInfo["asset.networkadapter.dhcpserver.0"]
    $Device.WarrantyExpiryDate = $DeviceAssetInfo["asset.device.warrantyexpirydate"]
	$Device.Customer = $DeviceAssetInfo["asset.customer.customername"]
	
	
 	
	$Script:Devices += $Device

	Remove-Variable DeviceAssetInfo
	}

#
##### Output File ---------------------------------------------------------------------------------------------------------
#

$Devices | Export-Csv -Path "C:\test\GetAssetDetails_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv" -NoTypeInformation

 
```

```json Response Example
{"success":true}
```

# Determin Server location

<!-- powershell@14 -->

Enter in N-central URL

# Generate Namespace

<!-- powershell@17-39 -->



# Create DeviceData and DeviceIdentifiers

<!-- powershell@40-49 -->



# Create DeviceData and DeviceIdentifiers data types to hold info





# CSV column outputs

<!-- powershell@50-85 -->

Defining the output columns in the CSV file

# Get Credentials

<!-- powershell@86-112 -->



# Select the output file

<!-- powershell@113-121 -->



# Uncomment the line below and the final line of the script to get output in a CSV file





# Execute the Query

<!-- powershell@122-220 -->



# Output file

<!-- powershell@223 -->