Hello.
I'm trying to use Dynamics SDK via Powershell, I tried to work with WebResources:
Here is my script:
<code>
$webResourcePat = "C:\Test\___default.html"
$wr = New-Object -TypeName Microsoft.Xrm.Sdk.Entity -ArgumentList "webresource"
$wr["name"] = $webResourceName;
$wr["displayname"] = $webResourceName;
//$web_res_FileContent_Text = [IO.File]::ReadAllText($webResourcePath)
$web_res_FileContent_Text = [IO.File]::ReadAllText("C:\Test\___default.html")
$web_res_FileContent_bytes = [System.Text.Encoding]::Unicode.GetBytes($web_res_FileContent_Text)
$base64_web_res_content = [Convert]::ToBase64String($web_res_FileContent_bytes)
//$wr["content"] = Get-Base64 $webResourcePath;
$wr["content"] = $base64_web_res_content
if (("C:\Test\___default.html").Contains(".htm"))
{
$wr["webresourcetype"] = New-Object -TypeName Microsoft.Xrm.Sdk.OptionSetValue -ArgumentList 1;
}
$wr["webresourcetype"] = [Microsoft.Xrm.Sdk.OptionSetValue]$wr["webresourcetype"];
try
{
$id = $service.Create($wr); // ERROR : Cannot find an overload for "Create" and the argument count: "1".
$publishXmlRequest += [string]::Concat("<webresource>", $id, "</webresource>");
Write-Host "Done!" -ForegroundColor Green -NoNewline;
$publish = $true;
}
catch [Exception]
{
Write-Host "Failed! [Error : $_.Exception]" -ForegroundColor Red;
continue;
}
</code>
I Have error:
Cannot find an overload for "Create" and the argument count: "1".
How can I fix if ?
Thank you