Question

I need to add the computer to the Event Log Readers group. I had tried the below script.

$hostName = "Hostname"
$computername = $env:computername
$EventLogGroup = [adsi]"WinNT://$computername/Event Log Readers,group"
$temp = "WinNT://$hostName"
$EventLogGroup.Add($temp)

The same script worked for adding the user to group and for adding the computers its not adding.

Object types we need to change to Computers I think. Locations will be in same domain.

Any modifications or alternative script will be helpful

"A member could not be added to or removed from the local group because the member does not exist" this is the error I am getting while executing the script

Était-ce utile?

La solution

Try to add the domain name and a dollar sign after the computer name:

$temp = "WinNT://DomainName/$hostName$,computer"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top