AXISHK
asked on
Retrieve administrator right and software installed on the domain workstation
Is it possible to use Powershell or VBscript to scan all domain workstations and list out which users has the local domain right , together with the software installed on their workstations ?
Thanks
Thanks
ASKER
I have put the following under c:\get-localadministrators .ps1 and then run it. I have open a powershell and execute the following :
c:\get-localadministrators -computername mydomain-computer01
However, no result is display. Any idea ??
function get-localadministrators {
param ([string]$computername=$en v:computer name)
$computername = $computername.toupper()
$ADMINS = get-wmiobject -computername $computername -query "select * from win32_groupuser where GroupComponent=""Win32_Gro up.Domain= '$computer name',Name ='administ rators'""" | % {$_.partcomponent}
foreach ($ADMIN in $ADMINS) {
$admin = $admin.replace("\\$compute rname\root \cimv2:Win 32_UserAcc ount.Domai n=","") # trims the results for a user
$admin = $admin.replace("\\$compute rname\root \cimv2:Win 32_Group.D omain=","" ) # trims the results for a group
$admin = $admin.replace('",Name="', "\")
$admin = $admin.REPLACE("""","")#st rips the last "
$objOutput = New-Object PSObject -Property @{
Machinename = $computername
Fullname = ($admin)
DomainName =$admin.split("\")[0]
UserName = $admin.split("\")[1]
}#end object
$objreport+=@($objoutput)
}#end for
return $objreport
}#end function
c:\get-localadministrators
However, no result is display. Any idea ??
function get-localadministrators {
param ([string]$computername=$en
$computername = $computername.toupper()
$ADMINS = get-wmiobject -computername $computername -query "select * from win32_groupuser where GroupComponent=""Win32_Gro
foreach ($ADMIN in $ADMINS) {
$admin = $admin.replace("\\$compute
$admin = $admin.replace("\\$compute
$admin = $admin.replace('",Name="',
$admin = $admin.REPLACE("""","")#st
$objOutput = New-Object PSObject -Property @{
Machinename = $computername
Fullname = ($admin)
DomainName =$admin.split("\")[0]
UserName = $admin.split("\")[1]
}#end object
$objreport+=@($objoutput)
}#end for
return $objreport
}#end function
Because you cannot specify computer name. It is taken from system variable $env:computername
To use it with different name, you need to change code a little bit.
And to that script, you need to add one more line at the end
get-localadministrators
Then run script again
Krzysztof
To use it with different name, you need to change code a little bit.
And to that script, you need to add one more line at the end
get-localadministrators
Then run script again
Krzysztof
ASKER
It works but I have a question,
get-localadministrators is a self -defined script and I suppose $computername will accept my passing parameter, ie. mydomain-computer01
But why do I need to include a call to itself at the end of the line.
Tkx
get-localadministrators is a self -defined script and I suppose $computername will accept my passing parameter, ie. mydomain-computer01
But why do I need to include a call to itself at the end of the line.
Tkx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tks
Local administrators
http://andrewmorgan.ie/2011/06/10/retrieve-a-list-of-local-administrators-using-powershell/
Installed software
http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/13/use-powershell-to-quickly-find-installed-software.aspx
for more advanced help, please wait for PowerShell experts
Regards,
Krzysztof