-
Notifications
You must be signed in to change notification settings - Fork 0
Script error at call for targetcred variable #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
All good. I sorted it myself. Had to remove the regex login and use New-ADObject instead. Also removed requirement for target creds as they are not required (and fail the script) if specified. Only source creds are required. This script allows updating PKI objects in Active Directory for thecross-forest certificate enrollment#This sample script is not supported under any Microsoft standard support (including, without limitation, damages for loss of business profits, business#interruption, loss of business information, or other pecuniary loss) arising Command line variables$SourceForestName = "" $ObjectType = "all" $DryRun = $FALSE function ParseCommandLine()
} function Usage() Build a list of attributes to copy for some object typefunction GetSchemaSystemMayContain($ForestContext, $ObjectType)
} Copy or delete all objects of some typefunction ProcessAllObjects($SourcePKIServicesDE, $TargetPKIServicesDE, $RelativeDN)
} Copy or delete an objectfunction ProcessObject($SourcePKIServicesDE, $TargetPKIServicesDE, $RelativeDN, $ObjectCN)
} Get parent container for all PKI objects in the ADfunction GetPKIServicesContainer([System.DirectoryServices.ActiveDirectory.DirectoryContext] $ForestContext, $dcName, $TargetCred)
} function GetPKIServicesContainerSource([System.DirectoryServices.ActiveDirectory.DirectoryContext] $ForestContext, $dcName, $SourceCred)
} ######################################################### Main script code######################################################### $SourceCred = Get-Credential -Message "Enter credentials for Source Forest" All errors are fatal by default unless there is another 'trap' with 'continue'trap ParseCommandLine Get a hold of the containers in each forestwrite-host ("Target Forest: " + $TargetForestName.ToUpper()) Only need source forest when copyingif($FALSE -eq $Script:DeleteOnly) if("" -ne $ObjectType) {write-host ("Object Category to process: " + $ObjectType.ToUpper())} Process the commandswitch($ObjectType.ToLower()) |
Hi there,
I know this is a long shot based on the age of the script, but I am trying to use this in an environment that does not allow an account with privileges for multiple forests, so I need to specify credentials. When trying to run your script, I receive the following error:
C:\temp\pkisync2.ps1 : The script has encoutnered a fatal error. Terminating script.
At line:1 char:1
Cannot find an overload for "Replace" and the argument count: "6".
At C:\temp\pkisync2.ps1:283 char:11
line 283 is:
$($TargetCred.GetNetworkCredential().password),
which is part of the GetPKIServicesContainer function
Seems that something doesn't like the number of arguments tied to the regex replace but only a guess.
If you have any idea as to what I am doing wrong, please let me know!
The text was updated successfully, but these errors were encountered: