使用PowerShell远程注册DNS中的记录

时间:2016-09-02 07:23:32

标签: powershell dns

以下是我的剧本,如果遗漏了某些内容,请告诉我。

#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 个答案:

答案 0 :(得分: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