$Group is an object, but you will actually need to check if $Group.samaccountname.StartsWith("string").
Change $Group.StartsWith("S_G_") to $Group.samaccountname.StartsWith("S_G_").
$Group is an object, but you will actually need to check if $Group.samaccountname.StartsWith("string").
Change $Group.StartsWith("S_G_") to $Group.samaccountname.StartsWith("S_G_").