I posted yesterday and received some excellent assistance getting a powershell script working. Today I have built upon that functionality and trying make it so the script will run against multiple computers. Everything works fine if I use ‘invoke-command’ to connect to the remote servers. When I try and use ‘Enter-PSSession’ I get the following error:
PS>TerminatingError(Enter-PSSession): "A positional parameter cannot be found that accepts argument ’
Here is my script:
#Script to identify all zones on a DNS server and enable zone transfers #Creates a log file of Zone Transfer setting prior to any changes Start-Transcript .\ZoneTransferInfo.txt #Specifies the Domain Controllers to run #$DomainControllers = Get-Content .\DomainControllers.txt foreach ($DC in $DomainControllers) { Write-Output "*********************************************************************************************************" Write-Output " " Write-Output $DC Write-Output " " Enter-PSSession -Computername $DC { #Prints the Current Zone Transfer settings Write-Output " " Write-Output "DNS Zone Transfer Settings prior to changes" Write-Output " " Get-DNSServerZone | select-object ZoneName, SecureSecondaries #Creates the collection containing the ZoneNames and then changes the setting to TransferAnyServer Write-Output "***************************************************************************" Write-Output " " Write-Output "Making Changes" Write-Output " " $NoSecureSecondaries = Get-DNSServerZone | select -expand ZoneName foreach ($zonename in $NoSecureSecondaries) { Try { Set-DNSServerPrimaryZone -Name "$zonename" -SecureSecondaries "TransferAnyServer" -PassThru } Catch { Write-Output $zonename "Zone Transfer Settting cannot be changed" } } Write-Output " " Write-Output "End of changes" Write-Output " " #Prints the Zone Transfer settings after the changes have been applied Write-Output "***************************************************************************" Write-Output " " Write-Output "DNS Zone Transfer Settings after changes" Write-Output " " Get-DNSServerZone | select-object ZoneName, SecureSecondaries } } Stop-Transcript Exit
I would like to use ‘Enter-PSSession’ as I am keeping a log of the session and when I use Invoke-Command there is a lot of noise and the log is not as clean data wise.
Any ideas and suggestions are greatly appreciated.
Thanks in advance.