Monday 15 September 2014

powershell - Stop script after setting value -


I wrote the script below with the help of this forum.

Am I trying to see a user on every GC replication and once it has been found that the server name is written in the set-adverwerting -preferredserver option.

The only thing I can not do is to work when it is written for the first time after successfully writing it. It runs through every GC and determines the value.

Do anyone have any ideas?

I have put some writing in host command for testing, but maybe it was removed after solving it.

  Obtain the import-module Active Directory - PSSession | Remove- PSSession $ session = new- PSSession- Configuration Name Microsoft.Exchange -ConnectionUri $ ConnectionURI- Authentication Kerberos Import- PSSession $ session- Allow Cloer- Warning Quietly Continue | Out Null $ GC = Mill-Edenan Controller -Filters {Eglobal Kastel-EC $ true} Forchach ($ gc in $ gc) {$ gcdpoint = "{0}: 3268" -f $ gc.hostname $ search result = ad- Adver - LDAP filter "(& amp; (samaccountname = $ ADUserName)) - Server $ Gendendpoint - SEARCHbase $ $ AddomainDN- Error Action SilentlyContinue if (@ ($ SearchResult) .account -gt 0) {$ ADServer = $ GC.hostname Type-Host $ ADServer Set-ADServerSettings- Predefined $ Ad $$ AD = Get-adserversettings $ Ad = $ AD | Select user preferver GlobalCell - Host "Favorite Server - $ ADS"}}  


No comments:

Post a Comment