I am trying to clean up my code a bit and im trying to make a class of sort to be called with other functions. Here is the code:
Function Invoke-SoapRequest {
param(
[parameter(Mandatory)]$Body,
[parameter(Mandatory)]$MethodName
)
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("SOAPAction", "CUCM:DB ver=10.5 $MethodName")
$headers.Add("Content-Type", "text/xml; charset=utf-8")
$headers.Add("Acc", "text/xml")
$headers.Add("Authorization", "Basic nonubusiness")
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};
Invoke-RestMethod 'https://cucm/axl/' -Method 'POST' -Headers $headers -credential $pscred
}
function Sync-LDAP
{
$AXL = @"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.5/">
<soapenv:Header/>
<soapenv:Body>
<ns:doLdapSync>
<name>LDAP</name>
<sync>true</sync>
</ns:doLdapSync>
</soapenv:Body>
</soapenv:Envelope>
"@
Invoke-SoapRequest -Body $AXL -MethodName doLdapSync
}
Sync-LDAP
In my mind this should work as intended, but the powershell command is get malformed or something and this is not working at all. Any assistance would be appreicated.