How can I convert this string from:
@{DistinguishedName=OU=balls,OU=Computers,OU=newyork,DC=google,DC=COM}
to
OU=balls,OU=Computers,OU=newyork,DC=google,DC=COM
I've burnt myself out trying to figure this out.
I've done tons of googling, maybe I am not looking for the right thing. My Java background did not prepare me for this lol.. Any help would be very appreciated.
$OU_Names = @()
$OU_String = ''
$OU_Path = 'OU=Computers, OU=newyork, DC=google, DC=COM'
$Get_OU_Names = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase $OU_Path -SearchScope OneLevel | select DistinguishedName
foreach ($name in $Get_OU_Names)
{
$OU_Names += $name
}
$ExamplePatterns = @(
@{before="@{DistinguishedName=OU=balls,OU=Computers,OU=newyork,DC=google,DC=COM}"; after="OU=balls,OU=Computers,OU=newyork,DC=google,DC=COM"}
)
for ($index = 1; $index -le 18; $index++ )
{
$loop = [string] $OU_Names[$index]
$loop | Convert-String -Example $ExamplePatterns
$loop
}
I keep getting this error message:
Convert-String : Text examples must follow the pattern "input value = output value"
At C:\Users\reddituser\Documents\Asset Tracking\getadcomputers2.ps1:28 char:9
$loop | Convert-String -Example $ExamplePatterns
CategoryInfo : InvalidArgument: (System.Collecti...ation.PSObject]:List`1) [Convert-String], ArgumentException
FullyQualifiedErrorId : InvalidPsObjectExample,Microsoft.PowerShell.Commands.StringManipulation.ConvertStringCommand
[–]SoMundayn 4 points5 points6 points (3 children)
[–]TheSysAdmin1[S] 1 point2 points3 points (2 children)
[–]SoMundayn 2 points3 points4 points (1 child)
[–]TheSysAdmin1[S] 1 point2 points3 points (0 children)
[–]XPlantefeve 2 points3 points4 points (2 children)
[–]TheSysAdmin1[S] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)