Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED Create approved request in SMS_UserApplicationRequest class.

Status
Not open for further replies.

chandumudda

New Member
Messages
2
Solutions
1
Reaction score
0
Points
1
I'm trying to automate "Approve application request per user per device" feature, I'm stuck at creating approved request using SMS_UserApplicationRequest class. I'm using .Net to automate it.

Please help me with your answers.
 
Solution
I did not get straight forward approach, so I used below SQL script to create Approved Request first and then used "SMS_UserApplicationRequest" Management Object class to Approve, Reject or RetryIntstall the request.
SQL Script to create approved request:
INSERT INTO UserApplicationRequests(UserID, MachineResourceID, ApplicationID, ModelID, CurrentState, LastChanged, LastChangedBy, Comments, Source, RequestGuid)
VALUES(@UserID, @MachineResourceID, @ApplicationID, @ModelID, @CurrentState, @LastChanged, @LastChangedBy, @Comments, @Source, @RequestGuid)

VB.Net code to Approve, Reject or RetryInstall:
Dim approveRequestClass As New ManagementClass("SMS_UserApplicationRequest")
Dim moConn As ManagementScope = GetManagementScope()

If...
I'm trying to automate "Approve application request per user per device" feature, I'm stuck at creating approved request using SMS_UserApplicationRequest class. I'm using .Net to automate it.

Please help me with your answers.
Hi, Did you get a solution for this? I am also stuck at the same place while trying to Automate SCCM Application Installation though .Net
 
I did not get straight forward approach, so I used below SQL script to create Approved Request first and then used "SMS_UserApplicationRequest" Management Object class to Approve, Reject or RetryIntstall the request.
SQL Script to create approved request:
INSERT INTO UserApplicationRequests(UserID, MachineResourceID, ApplicationID, ModelID, CurrentState, LastChanged, LastChangedBy, Comments, Source, RequestGuid)
VALUES(@UserID, @MachineResourceID, @ApplicationID, @ModelID, @CurrentState, @LastChanged, @LastChangedBy, @Comments, @Source, @RequestGuid)

VB.Net code to Approve, Reject or RetryInstall:
Dim approveRequestClass As New ManagementClass("SMS_UserApplicationRequest")
Dim moConn As ManagementScope = GetManagementScope()

If moConn Is Nothing Then
Return False
End If

moConn.Connect()
approveRequestClass.Scope = moConn
Dim approveRequestObj As ManagementObject = approveRequestClass.CreateInstance()
approveRequestObj("RequestGuid") = requestGuid 'Unique GUID created in above SQL Script

approveRequestObj.InvokeMethod("Approve", New Object() {"Approved for comments", 5}) 'For approving
approveRequestObj.InvokeMethod("Deny", New Object() {"Rejected for comments", 5}) 'For denying
approveRequestObj.InvokeMethod("RetryInstall", New Object() {"Retried comments", 5}) 'For retry


Hope this helps.
 
Solution
Status
Not open for further replies.
Back
Top