How can you read the v_GS_SoftwareFile table from SCCM?

PennyC
Tera Expert

Need to see the v_GS_SoftwareFile data from SCCM and don't see it from SCCM Graph Connector.  If it is in the graph connector which Data Source?

1 REPLY 1

Shivalika
Mega Sage

Hello @PennyC 

 

This is stored in "CM_<SiteCode>" database of SCCM Server. If you are not obtaining it by import. Then if you are having access to their instance via any service account, you can use REST API. 

 

 "https://<SCCMServer>/smsprovider/v1.0/SoftwareInventory" -Method Get -Headers @{"Authorization"="Bearer <YourToken>"}

 

Additionally you can also use powershell. 

 

$SCCMServer = "YourSCCMServer"

$Database = "CM_<SiteCode>"

$Query = "SELECT Name0, FilePath0, FileSize0 FROM v_GS_SoftwareFile WHERE Name0 LIKE '%.exe%'"

 

$connection = New-Object System.Data.SqlClient.SqlConnection

$connection.ConnectionString = "Server=$SCCMServer;Database=$Database;Integrated Security=True"

$connection.Open()

 

$command = $connection.CreateCommand()

$command.CommandText = $Query

$reader = $command.ExecuteReader()

 

while ($reader.Read()) {

    Write-Output "$($reader['Name0']) - $($reader['FilePath0']) - $($reader['FileSize0']) bytes"

}

 

$connection.Close()

 

Replace with exact server name that they have provided and also exact sitecode. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY