I'm not able to get the following powershell script to run in cmd prompt. The script will list all ad groups for a USERNAME and it works great in powershell. I want to be able to do this in cmd prompt so I can eventually automate the process in VBA. But I can't seem to configre the string correctly.
this is my code in command prompt with the error:
C:\Users\USERNAME>powershell -command "(New-Object System.DirectoryServices.DirectorySearcher(""(&(objectCategory=User)(samAccountName=USERNAME))"")).FindOne().GetDirectoryEntry().memberOf | clip"
The string is missing the terminator: ".
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString