2016-09-02 3 views
0

Ниже приведен мой сценарий. Пожалуйста, дайте мне знать, если что-то не хватает.Регистрация записи в DNS удаленно с помощью powershell

#Script to add DNS 'A' Records 'PTR' Records to DNS Servers 
$dns = "afidc1.XXXXXXX.com" # Your DNS Server Name 
$Zone = "XXXXXXX.com" # Your Forward Lookup Zone Name 
$IP = "X.X.X.X" 
$Name = "pweb17s1" 
$localuser = "XXXXXX\mayigi01" 
$localpass = "XXXXXX" 
Enter-PSSession –ComputerName $dns -GuestCredential $localuser $localpass 
Import-Module DnsServer 
Add-DnsServerResourceRecordA –ComputerName $dns -Name $Name -IPv4Address $IP -ZoneName $Zone 

Ниже ошибка утра облицовочный:

Enter-PSSession : A positional parameter cannot be found that accepts argument 'â€ComputerName 'afidc1.XXXXX.com' 
-GuestCredential XXXXX\mayigi01 XXXXX 
Import-Module DnsServer 
Add-DnsServerResourceRecordA â€ComputerName'. 
At C:\Users\devoops!\Desktop\dns.ps1:9 char:1 
+ Enter-PSSession –ComputerName 'afidc1.XXXXX.com' -GuestCredential $localus ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Enter-PSSession], ParameterBindingException 
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.EnterPSSessionCommand 
+1

Замените - перед ComputerName - –

+0

@ MathiasR.Jessen it dint work! Я получаю такую ​​же ошибку после замены –

+0

. Тогда вы ее не заменили - редактируете ли вы свой скрипт в Word или каком-то другом текстовом процессоре? –

ответ

0

Я использовал ISE:

просто скопировать его отсюда, может быть?

#Script to add DNS 'A' Records 'PTR' Records to DNS Servers 
$dns = "afidc1.XXXXXXX.com" # Your DNS Server Name 
$Zone = "XXXXXXX.com" # Your Forward Lookup Zone Name 
$IP = "X.X.X.X" 
$Name = "pweb17s1" 
$localuser = "XXXXXX\mayigi01" 
$localpass = "XXXXXX" 
Enter-PSSession -ComputerName $dns -GuestCredential $localuser $localpass 
Import-Module DnsServer 
Add-DnsServerResourceRecordA –ComputerName $dns -Name $Name -IPv4Address $IP -ZoneName $Zone