Tuesday, February 4, 2014

querying AD using custom queries

Here is how you can use AD custom queries from querying AD objects. I wanted to query user name, email.

1. Launch Active Directory users and Computers, and select Saved Queries. Right Click Saved Queries – > new – > query

2. Give a name to the Query

3. Select the Define Query Button, Under Find select Custom Search.

After selecting Custom Search select the Advanced Tab

In the Enter LDAP query window paste the following basic query string and hit OK
(&(objectcategory=person)(objectclass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))

4. The Query will display the result

In order to extract more data follow the next step
5. Go to View and Select Add/Remove Columns ..

6. Add or remove the Columns You need

7. Right Click on the Query and select Export List


Save as a CSV.

Thanks to http://pdtechguru.wordpress.com/2012/10/15/how-to-query-active-directory-objects-3/

Also, the complete list of UAC bits:
http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx#Examples

Friday, April 26, 2013

FEP sub reports error - Sub report could not be opened

While running  FEP reports, specially Antimalware Protection Summary Report, I was getting this error - Sub Report could not be opened.

If you open the report directly, you get this error - Query execution failed for dataset 'dsAMProtectionBreakdown'. (rsErrorExecutingCommand) Error 7202, Procedure -, Line 1, Message Could not find server 'FEPDW_ODU_FEPDW_ODU_OLAPProvider_FEP' in sys.servers.

Solution:
Open SQL Management Studio and try to do a test connection for the linked server - FEPDW_ODU_FEPDW_ODU_OLAPProvider_FEP and for the other one also.

The Test Connection should succeed. Check why it is not succeeding. I had my SQL Analysis Services stopped. Maybe delete the linked server and create it with correct database name.

Wednesday, January 23, 2013

GPO Preferences: Scheduled Tasks not appearing

Recently, I was required to create scheduled tasks for Windows 7 computers through GPO.

I did it through GPO:


But, the task was not appearing on the target workstation, no matter what.

After checking everything, I changed the logon credentials.By default tasks configured via the Computer section of Group Policy will run as %LogonDomain\%LogonUser%. But I changed it to BUILTIN\SYSTEM.

It's wrong. It should be NT AUTHORITY\SYSTEM, which works perfectly. The task appears on the target computers.

Sunday, November 18, 2012

Export Bitlocker Recovery Keys for a list of computers

If you want to generate a list of computers and their Bitlocker keys, then you can use this command. This will generate the keys in CSV format:


Adfind -b ou=xxx,ou=xxxxxx,ou=xxxx,ou=xxxxx,dc=xxx,dc=xxxx -csv -csvdelim # -f "(msFVE-RecoveryPassword=*)" msFVE-RecoveryPassword > bitlocker_keys.txt


Replace xxx with correct distinguished names of the required OU.
You need to have access to Bitlocker recovery keys.

Thursday, November 15, 2012

Running VBScripts on Vista/Win 7 64 bit computers

Sometimes while running vbscripts on Win 7 64 bit computers, the script gives errors in creating objects or unable to access shares.

The reason is that vbscripts are being executed as 64 bit scripts.

Some DLLs do not support 64 bits, so the script has to be run wit hthe 32 bit version of WScript.exe from the directory %SystemRoot%\SysWOW64 or the global Registry setting has to be changed:
HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command
(Standard) from
"%SystemRoot%\System32\WScript.exe" "%1" %*
to
"%SystemRoot%\SysWOW64\WScript.exe" "%1" %*

Wednesday, September 19, 2012

Mssing SCCM Performance Counters

I was facing this strange issue of not able to find all those SMS_**** performance montor counters.

Tried the LODCTR commands and rebooted the server, but it did not help.
Even went into every SMS folder under c:\windows\inf, and run the command to rebuild SMS Counters

Lodctr /R:<filename>. But it didnt work.


Finally, Microsoft support provided me this solution that worked.



Open cmd prompt (run as administrator).
Go to the installation location of ConfigMgr.
Eg:
C:\Program files (x86)\Microsoft Configuration Manager\bin\i386>
Type in the following:
Perfsetup.exe /install /siteserver:<ServerName> SMS_WSUS_SYNC_MANAGER
Eg:
Perfsetup.exe /install /siteserver:SCCMCEN SMS_WSUS_SYNC_MANAGER
Check the PErfsetup.log for any errors.

Once I followed the above steps I was able to see all the Perf Counters for SMS.

For MSSQLServer counters:

Open this registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MSSQLSERVER\Performance
Check the value of PerfINIFile.
Open cmd prompt.
Go to SQL Bin folder - C:\Program Files\Microsoft SQL Server\...Bin
Run this command lodctr sqlctr.ini
And lodctr perf-MSSQLSERVERsqlctr.ini (value found for PerfINIFile).

Restart SQL service.  
 



Wednesday, July 25, 2012

Script to move package to another folder

Recently i was required to move some packages to an 'Archive' folder. Instead of doing this manually, I created this script. The list of packages has to be put into the array in the script:


Option Explicit
'On error resume next

Dim strSMSServer, strSMSSiteCode, strPackageIDs
Dim intSourceFolder, intDestFolder, intObjectType
Dim loc, objSMS
Dim objFolder
Dim arrPackageIDs
Dim retval

strSMSServer   = "xxx"
strSMSSiteCode = "xxx"
strPackageIDs  = "99900048,9990004B..." 'to move more than one, separate with commas

intSourceFolder = 0 'Source Folder (In Production=8, Root=0)
intDestFolder   = 310 'Destination Folder (TobeDeleted = 310)
intObjectType   = 2 '2=Package for type of object

Set loc         = CreateObject("WbemScripting.SWbemLocator")
Set objSMS      = loc.ConnectServer(strSMSServer, "root\SMS\site_" & strSMSSiteCode)

Set objFolder = objSMS.Get("SMS_ObjectContainerItem")
arrPackageIDs = Split(strPackageIDs, ",")

retval = objFolder.MoveMembers(arrPackageIDs, intSourceFolder , intDestFolder , intObjectType)
If Err.Number <> 0 Then
    Wscript.Echo Err.Description
End Ifss

Wscript.echo "Done"

-----

to get the folder numbers, use this:

strSiteCode = "xxx"

Set SWBemlocator  = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"\root\sms\site_" & strSiteCode,UserName,Password)

Dim AdvertisementInfo, objItem
Set AdvertisementInfo = objWMIService.ExecQuery ("select * from SMS_ObjectContainerNode") ' where Name = '" & FolderName & "'")
For Each objItem in AdvertisementInfo
    wscript.echo "The folder node ID for """ & objItem.Name & """ is: " & objItem.ContainerNodeID
Next