Hello.
So, I've been working with Powershell for about a week. Finally decided to dive in, and I'm stuck
What I'm trying to do is grab all the services running as a domain account and run that through Get-ADUser to grab some of the properties for that account. Problem #1 is the script below comes back with
the domain appended to the front: AB\ServiceAccountName
Get-WmiObject -ComputerName $StrComputer Win32_Service | select-object startname | Where-Object {$_.startname -like "AB\*"}
$ServiceAccount=$_.startname
Get-ADUser doesn't like the AB\ in front of the name (or if it does, I'd love to know how). So, I've looked at stripping off the first three characters, AB\, and passing that to Get-ADUser via this:
$ServiceAccount=$ServiceAccount.Substring(3)
This gives the error:
Method invocation failed because [Microsoft.ActiveDirectory.Management.ADPropertyValueCollection] doesn't contain a method named 'substring'.At line:6 char:42
+ $serviceaccount=$serviceaccount.substring <<<< (3)
+ CategoryInfo : InvalidOperation: (substring:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
I'm at a loss. Any help or pointing in the right direction would be greatly appreciated.