Quick PS Help (I think)

Hey all,

I’m no powershell expert by any means, but I have a script that works on some computernames, but not others, I’m hoping I’m just overlooking something simple if someone can take a glance at it.

Get-ADUser -Filter ‘enabled -eq $true’ -Properties LogonWorkstations | Where-Object {$_.LogonWorkstations -eq “ComputerName” } | Select-Object -Property samaccountname, name, LogonWorkstations

The point of this is for Helpdesk people be able to quickly determine who has logon rights for specific computers. It works great if the name is “computername”. However a large number or our computers have hyphens, “computer-name”. The script doesn’t generate any errors on these, but it also doesn’t return any results, when there should definitely be returns.

I’ve tried single quotes, escaping just the hyphen,

also changing the line to

Where-Object -Property LogonWorkstations -eq ‘Computername’ and I still get zero returns on names with hyphens.

Any help would be appreciated. 🙂

submitted by /u/disdainmsh
[link] [comments]

Leave a Reply