I have a few of these scripts in Powershell I posted to my blog at
http://sentinel24.com/blog/?page_id=51 . One example recurses through a file structure and adds permissions for a user
(FYI - I use the long form for Powershell syntax when writing tutorials but you can make this much shorter using gci, gwmi, ft, etc)
Get-ChildItem -recurse * | ForEach-Object -process { $_.FullName } | % { c:\subinacl.exe /file $_ /grant=domain\username=F}
Obviously this won't work for services, so how to accomplish the same thing?
First I want to enumerate services, but I want to sort based on startmode and name and suppress everything except for the service name. (no status or table headers for example)
Get-WmiObject -computer computername win32_service | sort startmode, displayname | Format-Table -property Displayname -HideTableHeaders
I'm not 100% sure what you are hoping to accomplish here, but if you wanted to add an account entry for each of those you can combine the 2 scripts into something like
Get-WmiObject -computer computername win32_service | sort startmode, displayname | Format-Table -property Displayname -HideTableHeaders | ForEach-Object -process { $_.FullName } | % { "C:\Program Files\Windows Resource Kits\Tools\subinacl.exe /service $_ \\computername\$_ /grant=domain\username=F"}
http://ss64.com/nt/subinacl.html has additional subinacl syntax and is what I used when writing the scripts at my blog.
*Edit* While my way is more fun (I am addicted to making Powershell 1 liners!), I'd suggest checking out ajohnson's suggestion as that's probably closer to what you are looking for.
