AnsweredAssumed Answered

How do I Log Into Asset Management API with Azure Automation?

Question asked by Joey Odell on Mar 18, 2020

I'm trying to use Azure Automation to log into the Asset Management API with Azure Automation. I have an asset tag in Qualys that grabs all assets that have not been seen in a VM scan for over 14 days. I'm trying to list all assets with that tag.

 

<see attachment>

 

The output of the Assets.xml file is always blank and I keep getting errors. See below.

 

<content reformatted for readability>

 

Directory: C:\Temp\dycxogkm.b5x Mode LastWriteTime Length Name ---- ------------- ------ ---- ------ 3/18/2020 5:07 PM 0 file.xml ------ 3/18/2020 5:07 PM 0 Assets.xml Get Not-VM-Scanned-In-14-Days Error! Data: Count : 0 Keys : {} IsReadOnly : False IsFixedSize : False IsSynchronized : False SyncRoot : System.Object Values : {} Help Link: Hresult: -2146233079 Inner Exception: Message: The remote server returned an error: (500) Internal Server Error. Response: IsMutuallyAuthenticated : False Cookies : {ADRUM_BTa=R:0|g:1234567-1234-1234-1234-1234567890|n:Qualys_123456-1234-1234-1234-123456 12345, ADRUM_BT1=R:0|i:1678558|e:1943|d:96, ADRUM_BTs=R:0|s:f, ADRUM_BTh=R:0|h:e} Headers : {Set-Cookie, Content-Length, Date, Connection...} SupportsHeaders : True ContentLength : 0 ContentEncoding : ContentType : CharacterSet : Server : Apache LastModified : 3/18/2020 5:07:06 PM StatusCode : InternalServerError StatusDescription : ProtocolVersion : 1.1 ResponseUri : https://qualysapi.qg2.apps.qualys.com/qps/rest/2.0/search/am/hostasset Method : POST IsFromCache : False Source: Microsoft.PowerShell.Commands.Utility Stack Trace: at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() Status: ProtocolError bException Status: Target Site: Name : GetResponse DeclaringType : Microsoft.PowerShell.Commands.WebRequestPSCmdlet ReflectedType : Microsoft.PowerShell.Commands.WebRequestPSCmdlet MemberType : Method MetadataToken : 100665843 Module : Microsoft.PowerShell.Commands.Utility.dll IsSecurityCritical : True IsSecuritySafeCritical : False IsSecurityTransparent : False MethodHandle : System.RuntimeMethodHandle Attributes : PrivateScope, Assembly, Virtual, HideBySig, VtableLayoutMask, CheckAccessOnOverride CallingConvention : Standard, HasThis ReturnType : System.Net.WebResponse ReturnTypeCustomAttributes : System.Net.WebResponse ReturnParameter : System.Net.WebResponse IsGenericMethod : False IsGenericMethodDefinition : False ContainsGenericParameters : False MethodImplementationFlags : IL IsPublic : False IsPrivate : False IsFamily : False IsAssembly : True IsFamilyAndAssembly : False IsFamilyOrAssembly : False IsStatic : False IsFinal : False IsVirtual : True IsHideBySig : True IsAbstract : False IsSpecialName : False IsConstructor : False CustomAttributes : {} 2020-03-18 Directory: C:\Temp\dycxogkm.b5x Mode LastWriteTime Length Name ---- ------------- ------ ---- ------ 3/18/2020 5:07 PM 0 file.xml ------ 3/18/2020 5:07 PM 0 Assets.xml Get Not-VM-Scanned-In-14-Days Error! Data: Count : 0 Keys : {} IsReadOnly : False IsFixedSize : False IsSynchronized : False SyncRoot : System.Object Values : {} Help Link: Hresult: -2146233079 Inner Exception: Message: The remote server returned an error: (500) Internal Server Error. Response: IsMutuallyAuthenticated : False Cookies : {ADRUM_BTa=R:0|g:12345678-1234-1234-1234-123456789|n:Qualys_123456-1234-1234-1234-12344567 12345, ADRUM_BT1=R:0|i:1678558|e:1943|d:96, ADRUM_BTs=R:0|s:f, ADRUM_BTh=R:0|h:e} Headers : {Set-Cookie, Content-Length, Date, Connection...} SupportsHeaders : True ContentLength : 0 ContentEncoding : ContentType : CharacterSet : Server : Apache LastModified : 3/18/2020 5:07:06 PM StatusCode : InternalServerError StatusDescription : ProtocolVersion : 1.1 ResponseUri : https://qualysapi.qg2.apps.qualys.com/qps/rest/2.0/search/am/hostasset Method : POST IsFromCache : False Source: Microsoft.PowerShell.Commands.Utility Stack Trace: at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() Status: ProtocolError bException Status: Target Site: Name : GetResponse DeclaringType : Microsoft.PowerShell.Commands.WebRequestPSCmdlet ReflectedType : Microsoft.PowerShell.Commands.WebRequestPSCmdlet MemberType : Method MetadataToken : 100665843 Module : Microsoft.PowerShell.Commands.Utility.dll IsSecurityCritical : True IsSecuritySafeCritical : False IsSecurityTransparent : False MethodHandle : System.RuntimeMethodHandle Attributes : PrivateScope, Assembly, Virtual, HideBySig, VtableLayoutMask, CheckAccessOnOverride CallingConvention : Standard, HasThis ReturnType : System.Net.WebResponse ReturnTypeCustomAttributes : System.Net.WebResponse ReturnParameter : System.Net.WebResponse IsGenericMethod : False IsGenericMethodDefinition : False ContainsGenericParameters : False MethodImplementationFlags : IL IsPublic : False IsPrivate : False IsFamily : False IsAssembly : True IsFamilyAndAssembly : False IsFamilyOrAssembly : False IsStatic : False IsFinal : False IsVirtual : True IsHideBySig : True IsAbstract : False IsSpecialName : False IsConstructor : False CustomAttributes : {} 

Attachments

Outcomes