Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Querying group names containing dollar signs with WMI

$
0
0
I'm using Powershell (v2.0) to get the members of local groups on remote servers. I've got that working with the get-wmiobject cmdlet with one strange exception: If a local groupname contains a $, that character seems to be ignored in the name matching. For instance, I made two test groups on a server, test and test$sjs, each containing different users. I then runget-wmiobject -ComputerName 'PTS-GPSQL01' -query "select * from win32_groupuser where GroupComponent = `"Win32_Group.Domain='PTS-GPSQL01'`,Name='test'`""andget-wmiobject -ComputerName 'PTS-GPSQL01' -query "select * from win32_groupuser where GroupComponent = `"Win32_Group.Domain='PTS-GPSQL01'`,Name='test$sjs'`""But each command returns the members of the test group. I'm using a PS script function I found at http://gallery.technet.microsoft.com/scriptcenter/List-local-group-members-762b48c5. That contains a comment saying dollar signs will screw up the WMI query if they are in the computer name and filters them out of there. Seems they might mess up the group names too. And since SQL 2005 creates groups with names like SQLServer2005MSSQLUser$PTS-GPSQL01$MSSQLSERVER, that kinda makes things difficult.Has anyone come across a workarounds for this? Or am I missing something?Shaun

Viewing all articles
Browse latest Browse all 467

Trending Articles