Posts tagged Powershell

Enabling Remote WMI and DCOM by Command Line on Remote Computer

0

Enabling Remote WMI and DCOM for PowerShell Use
Many cmdlets have a built-in -ComputerName parameter that will allow for remote access without using the new PowerShell remoting. For this to work, your firewall will need to be adjusted on the target machine:
netsh firewall set service type = remoteadmin mode = enable
In addition, some cmdlets (like Get-Service) will need the Remote Registry service to be running on the target side:
Start-Service RemoteRegistry
Set-Service RemoteRegistry -StartupType Automatic

Powershell to Get the count of user objects in Active Directory using LDAP Query

0

$Domain = ‘LDAP://DC=yourdomain;DC=com’
$Root = New-Object DirectoryServices.DirectoryEntry $Domain
$select = New-Object DirectoryServices.DirectorySearcher
$select.SearchRoot = $root
$adobj= $select.findall() |? {$_.properties.objectcategory -match “CN=Person”}
$adobj.count

For the $Domain variable change the “yourdomain” string┬áto the name of your domain.