<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: Добавить запись в DNS]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15841</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15841&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: Добавить запись в DNS».]]></description>
		<lastBuildDate>Fri, 20 Nov 2020 12:43:44 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143573#p143573</link>
			<description><![CDATA[<p><strong>inock</strong>, колитесь, коллега <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" />.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Fri, 20 Nov 2020 12:43:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143573#p143573</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143571#p143571</link>
			<description><![CDATA[<p>Дело было не в бобине. Заработало.</p>]]></description>
			<author><![CDATA[null@example.com (inock)]]></author>
			<pubDate>Fri, 20 Nov 2020 11:50:54 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143571#p143571</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143567#p143567</link>
			<description><![CDATA[<p><strong>inock</strong>, а привилегий достаточно? Не пробовали задавать привилегии для Wbem в скрипте?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 19 Nov 2020 16:40:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143567#p143567</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143565#p143565</link>
			<description><![CDATA[<p>Powershell здесь не в тему, но тоже не работает <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />(</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p># Блок переменных<br /># $DNSServer - NetBIOS имя сервера DNS<br /># $DNSFZone - DNS зона прямого просмотра<br /># $DataFile - Путь к файлу CSV с входными данными<br />#<br />$DNSServer = &quot;bte-dc-01&quot;<br />$DNSFZone = &quot;ats.teplo.local&quot;<br />$DataFile = &quot;C:\TEMP\ats\Create-A-Records.csv&quot;<br />#<br /># Подключение к удалённому экземпляру WMI<br /># и обработка входных данных файла <br />#<br />$DNSRR = [WmiClass]&quot;\\$DNSServer\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord&quot;<br />$ConvFile = $DataFile + &quot;_unicode&quot;<br />Get-Content $DataFile | Set-Content $ConvFile -Encoding Unicode<br />Import-CSV $ConvFile -Delimiter &quot;;&quot; | ForEach-Object { <br />$FQDN = $_.HostName + &quot;.&quot; + $DNSFZone<br />$IP = $_.HostIP<br />$TextA = &quot;$FQDN IN A $IP&quot; <br />echo&nbsp; $TextA<br />echo $DNSFZone<br />echo $DNSServer<br />$DNSRR.CreateInstanceFromTextRepresentation($DNSServer,$DNSFZone,$TextA)<br />}<br />Remove-Item $ConvFile</p></div></div><div class="codebox"><pre><code>
C:\TEMP\ats&gt;powershell -F DNS-Create-A-Records-from-File.ps1
1063.ats.teplo.local IN A 10.32.99.166
ats.teplo.local
bte-dc-01
Исключение при вызове &quot;CreateInstanceFromTextRepresentation&quot; : &quot;Generic failure
 &quot;
C:\TEMP\ats\DNS-Create-A-Records-from-File.ps1:23 знак:44
+ $DNSRR.CreateInstanceFromTextRepresentation &lt;&lt;&lt;&lt; ($DNSServer,$DNSFZone,$TextA
)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WMIMethodException
</code></pre></div><p>При этом, с оснастки mmc, все работает нормально, без проблем.</p>]]></description>
			<author><![CDATA[null@example.com (inock)]]></author>
			<pubDate>Thu, 19 Nov 2020 14:23:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143565#p143565</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143564#p143564</link>
			<description><![CDATA[<p>Думаю, дело все-таки не в коде...</p><p>Вот второй вариант, но метод так же не выполняется</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>strHostName = &quot;test&quot;<br />strZoneName = &quot;ats.teplo.local&quot;<br />strIP = &quot;192.168.0.5&quot;<br />strServer = &quot;bte-dc-01&quot;</p><p>&#039;Set objDNS = GetObject(&quot;winMgmts:root\MicrosoftDNS&quot;)<br />Set objLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)<br />Set objDNS = objLocator.ConnectServer (strServer, &quot;root\MicrosoftDNS&quot;)<br />Set objRR = objDNS.Get(&quot;MicrosoftDNS_ResourceRecord&quot;)<br />Set objDNSServer = objDNS.Get(&quot;MicrosoftDNS_Server.Name=&quot;&quot;.&quot;&quot;&quot;)</p><br /><p>Dim strNull<br />strFullHost = strHostName &amp; &quot;.&quot; &amp; strZoneName &amp; &quot;. IN A &quot; &amp; strIP<br />wscript.echo strFullHost<br />strNull = objRR.CreateInstanceFromTextRepresentation( _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objDNSServer.Name, _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strZoneName, _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFullHost, _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objOutParam) </p><p>Set objRR2 = objDNS.Get(objOutParam)<br />WScript.Echo &quot;Created Record: &quot; &amp; objRR2.TextRepresentation</p></div></div><div class="codebox"><pre><code>C:\TEMP\ats&gt;cscript test__.vbs
test.ats.teplo.local. IN A 192.168.0.5
C:\TEMP\ats\test__.vbs(16, 1) SWbemObjectEx: Generic failure</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (inock)]]></author>
			<pubDate>Thu, 19 Nov 2020 14:17:00 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143564#p143564</guid>
		</item>
		<item>
			<title><![CDATA[VBS: Добавить запись в DNS]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=143552#p143552</link>
			<description><![CDATA[<p>Граждане, помогите написать код, добавляющий A-запись в днс?<br />Интернет облазил, нормальных примеров на VBS нет, только на PS.</p><p>Пока у меня так. Что делать дальше - никак не соображу.</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>strHostName = &quot;test&quot;<br />strZoneName = &quot;ats.teplo.local&quot;<br />strIP = &quot;192.168.0.5&quot;<br />strServer = &quot;bte-dc-01&quot;<br />strNameSpace = &quot;root\microsoftDNS&quot;</p><p>Set objLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)<br />Set objService = objLocator.ConnectServer (strServer, strNameSpace)<br />Set objDNS = objService.Get(&quot;MicrosoftDNS_ResourceRecord&quot;)<br />Set objMethod = objDNS.Methods_(&quot;CreateInstanceFromTextRepresentation&quot;)</p><p>&#039;wscript.quit</p><p>Set ObjInParam = objMethod.inParameters.SpawnInstance_()<br />ObjInParam.TextRepresentation = strHostName &amp; &quot;.&quot; &amp; strZoneName &amp; &quot;. IN A &quot; &amp; strIP<br />ObjInParam.DnsServerName = strServer<br />ObjInParam.ContainerName = strZoneName</p><p>wscript.echo ObjInParam.DnsServerName<br />wscript.echo ObjInParam.ContainerName<br />wscript.echo ObjInParam.TextRepresentation</p><p>Set ObjRR = objDNS.ExecMethod_(&quot;CreateInstanceFromTextRepresentation&quot;, ObjInParam)</p></div></div><p>Что имеем на выходе:<br /></p><div class="codebox"><pre><code>bte-dc-01
ats.teplo.local
test.ats.teplo.local. IN A 192.168.0.5
C:\TEMP\ats\test.vbs(23, 1) SWbemObjectEx: Generic failure</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (inock)]]></author>
			<pubDate>Thu, 19 Nov 2020 09:20:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=143552#p143552</guid>
		</item>
	</channel>
</rss>
