Wie fange ich von FullyQualifiedErrorId in der PowerShell?

Habe ich ein Skript erstellt neue AD-Objekte (via New-ADObject, wie es geschieht). Wenn das Objekt bereits vorhanden ist, ich müssen zu fangen und zu behandeln, dass. Allerdings ist die Ausnahme, der Typ ist nicht annähernd so explizit wie die FullyQualifiedErrorId. Beachten Sie die unten:

> $Error[-1] | Format-List -Property * -Force

writeErrorStream      : True
PSMessageDetails      : 
Exception             : Microsoft.ActiveDirectory.Management.ADException: An attempt was made to add an object to the directory with 
                    a name that is already in use ---> System.ServiceModel.FaultException: The supplied entry already exists.
                       --- End of inner exception stack trace ---
                       at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForExtendedError(String 
                    extendedErrorMessage, Exception innerException)
                       at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForFaultDetail(FaultDetail 
                    faultDetail, FaultException faultException)
                       at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowException(AdwsFault adwsFault, FaultException 
                    faultException)
                       at Microsoft.ActiveDirectory.Management.AdwsConnection.Create(ADAddRequest request)
                       at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADSy
                    ncOperations.Add(ADSessionHandle handle, ADAddRequest request)
                       at Microsoft.ActiveDirectory.Management.ADActiveObject.Create()
                       at Microsoft.ActiveDirectory.Management.Commands.ADNewCmdletBase`3.ProcessRecordOverride()
                       at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase.ProcessRecord()
TargetObject          : ou=Domain Controllers,DC=cryotest,DC=testdom
CategoryInfo          : NotSpecified: (ou=Domain Contr...test,DC=afcdom1:String) [New-ADObject], ADException
FullyQualifiedErrorId : An attempt was made to add an object to the directory with a name that is already in 
                    use,Microsoft.ActiveDirectory.Management.Commands.NewADObject
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Import-ADObjectOfClass, C:\Users\administrator\Desktop\Import-ADObjects.ps1: line 103
                    at <ScriptBlock>, C:\Users\administrator\Desktop\Import-ADObjects.ps1: line 137
                    at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {1, 1}

Wie kann ich die mehr ausführliche information hier in meinem Catch-block?

InformationsquelleAutor Tohuw | 2013-08-08
Schreibe einen Kommentar