Wednesday, August 24, 2011
Clean Up your active directory
or
dsquery computer "OU=WSUS,DC=ABC,DC=KW,DC=com" -limit 1000 > C:\WsusComputers.txt
or if it was under container use:
dsquery computer "CN=Computers,DC=ABC,DC=KW,DC=com" -limit 1000 > C:\WsusComputers.txt
2- Clean them up by Excel to allow only Computer name and then save them to file.
3- Use:
C:\>for /f %a in (C:\lookup.txt) do nslookup %a | find /i "Address" >> c:\nslookup_results.txt
to resolve them to IPs
4- Use angry IP scanner to resolve them to DNS again but with IPs matched & FqDN.
5- Export to Excel and filter to remove [ns] [na] invalid IPs
6- Move them to separate OU:
dsquery computer -name muhq-teller2.ABC.bh.com | dsmove -newparent ou=muharraq,ou=computers,ou=ABC,dc=kfh,dc=bh,dc=com
7- get list of inactive computers for last 90 days:
dsquery computer -inactive 90 -limit 0
And move them as above as well.
Monday, August 22, 2011
Move computer to another OU using DSMOVE
Saturday, August 20, 2011
Create a WinPe including Image X
C:\Program Files\Windows AIK\Tools\PETools\
C:\Program Files\Windows AIK\Tools\PETools\..\x86
C:\Program Files\Windows AIK\Tools\PETools\..\x86\Servicing;
C:\Program Files\Windows AIK\Tools\PETools>dir
Volume in drive C has no label.
Volume Serial Number is EC71-F518
Directory of C:\Program Files\Windows AIK\Tools\PETools
16/06/2011 02:01 PM
16/06/2011 02:01 PM
16/06/2011 02:03 PM
10/06/2009 02:44 PM 2,084 copype.cmd
16/06/2011 02:03 PM
10/06/2009 02:44 PM 806 pesetenv.cmd
10/06/2009 02:44 PM 3,485 setsanpolicy.cmd
14/07/2009 07:10 AM 116,096 ssshim.dll
16/06/2011 02:01 PM
4 File(s) 122,471 bytes
5 Dir(s) 16,468,791,296 bytes free
C:\Program Files\Windows AIK\Tools\PETools>cd x86
C:\Program Files\Windows AIK\Tools\PETools\x86>dir
Volume in drive C has no label.
Volume Serial Number is EC71-F518
Directory of C:\Program Files\Windows AIK\Tools\PETools\x86
16/06/2011 02:01 PM
16/06/2011 02:01 PM
16/06/2011 02:03 PM
13/07/2009 06:39 PM 383,562 bootmgr
14/07/2009 10:05 AM 103,312 BootSect.exe
16/06/2011 02:01 PM
13/07/2009 07:51 PM 114,088,185 winpe.wim
16/06/2011 02:03 PM
3 File(s) 114,575,059 bytes
5 Dir(s) 16,468,586,496 bytes free
C:\Program Files\Windows AIK\Tools\PETools\x86>cd \
C:\>cd Program Files\Windows AIK\Tools\PETools
C:\Program Files\Windows AIK\Tools\PETools>copype.cmd x86 c:\winpeFiles
===================================================
Creating Windows PE customization working directory
c:\winpeFiles
===================================================
1 file(s) copied.
1 file(s) copied.
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\bcd
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\boot.sdi
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\bootfix.bin
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\etfsboot.com
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\chs_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\cht_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\jpn_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\kor_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\wgl4_boot.ttf
9 File(s) copied
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\bcd
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\chs_boot
.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\cht_boot
.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\jpn_boot
.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\kor_boot
.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\wgl4_boo
t.ttf
6 File(s) copied
1 file(s) copied.
Success
Updating path to include peimg, cdimage, imagex
C:\Program Files\Windows AIK\Tools\PETools\
C:\Program Files\Windows AIK\Tools\PETools\..\x86
C:\winpeFiles>dir
Volume in drive C has no label.
Volume Serial Number is EC71-F518
Directory of C:\winpeFiles
20/08/2011 01:57 PM
20/08/2011 01:57 PM
10/06/2009 02:14 PM 4,096 etfsboot.com
20/08/2011 01:57 PM
20/08/2011 01:57 PM
13/07/2009 07:51 PM 114,088,185 winpe.wim
2 File(s) 114,092,281 bytes
4 Dir(s) 16,317,333,504 bytes free
C:\winpeFiles>copy c:\winpeFiles\winpe.wim c:\winpeFiles\ISO\sources\boot.wim
1 file(s) copied.
C:\winpeFiles>copy "c:\Program Files\Windows AIK\Tools\x86\imagex.exe" c:\winpeF
iles\ISO
1 file(s) copied.
C:\winpeFiles>oscdimg.exe -n -bc:\winpeFiles\etfsboot.com c:\winpeFiles\ISO c:\w
inpeFiles\ImageX.iso
OSCDIMG 2.55 CD-ROM and DVD-ROM Premastering Utility
Copyright (C) Microsoft, 1993-2007. All rights reserved.
Licensed only for producing Microsoft authorized content.
Scanning source tree
Scanning source tree complete (18 files in 8 directories)
Computing directory information complete
Image file is 142673920 bytes
Writing 18 files in 8 directories to c:\winpeFiles\ImageX.iso
100% complete
Final image file is 142673920 bytes
Done.
C:\winpeFiles>
Tuesday, August 16, 2011
Get SQL information
select * from sys.database_principals
select * from sys.database_permissions
//Get Databases on the system//
EXEC sp_databases
//database Users Roles//
SELECT p.NAME
,m.NAME
FROM sys.database_role_members rm
JOIN sys.database_principals p
ON rm.role_principal_id = p.principal_id
JOIN sys.database_principals m
ON rm.member_principal_id = m.principal_id
// Call Stored procedures from anther server//
EXEC [sqltest].Globalfs.dbo.List_DBRoles
====================
Store Procedure to
List all users roles, And permissions
====================CREATE procedure [dbo].[List_DBRoles]
(
@database nvarchar(128)=null,
@user varchar(20)=null,
@dbo char(1)=null,
@access char(1)=null,
@security char(1)=null,
@ddl char(1)=null,
@datareader char(1)=null,
@datawriter char(1)=null,
@denyread char(1)=null,
@denywrite char(1)=null
)
as
declare @dbname varchar(200)
declare @mSql1 varchar(8000)
CREATE TABLE #DBROLES
( DBName sysname not null,
UserName sysname not null,
db_owner varchar(3) not null,
db_accessadmin varchar(3) not null,
db_securityadmin varchar(3) not null,
db_ddladmin varchar(3) not null,
db_datareader varchar(3) not null,
db_datawriter varchar(3) not null,
db_denydatareader varchar(3) not null,
db_denydatawriter varchar(3) not null,
Cur_Date datetime not null default getdate()
)
DECLARE DBName_Cursor CURSOR FOR
select name
from master.dbo.sysdatabases
where name not in ('mssecurity','tempdb')
Order by name
OPEN DBName_Cursor
FETCH NEXT FROM DBName_Cursor INTO @dbname
WHILE @@FETCH_STATUS = 0
BEGIN
Set @mSQL1 = ' Insert into #DBROLES ( DBName, UserName, db_owner, db_accessadmin,
db_securityadmin, db_ddladmin, db_datareader, db_datawriter,
db_denydatareader, db_denydatawriter )
SELECT '+''''+@dbName +''''+ ' as DBName ,UserName, '+char(13)+ '
Max(CASE RoleName WHEN ''db_owner'' THEN ''Yes'' ELSE ''No'' END) AS db_owner,
Max(CASE RoleName WHEN ''db_accessadmin '' THEN ''Yes'' ELSE ''No'' END) AS db_accessadmin ,
Max(CASE RoleName WHEN ''db_securityadmin'' THEN ''Yes'' ELSE ''No'' END) AS db_securityadmin,
Max(CASE RoleName WHEN ''db_ddladmin'' THEN ''Yes'' ELSE ''No'' END) AS db_ddladmin,
Max(CASE RoleName WHEN ''db_datareader'' THEN ''Yes'' ELSE ''No'' END) AS db_datareader,
Max(CASE RoleName WHEN ''db_datawriter'' THEN ''Yes'' ELSE ''No'' END) AS db_datawriter,
Max(CASE RoleName WHEN ''db_denydatareader'' THEN ''Yes'' ELSE ''No'' END) AS db_denydatareader,
Max(CASE RoleName WHEN ''db_denydatawriter'' THEN ''Yes'' ELSE ''No'' END) AS db_denydatawriter
from (
select b.name as USERName, c.name as RoleName
from ' + @dbName+'.dbo.sysmembers a '+char(13)+
' join '+ @dbName+'.dbo.sysusers b '+char(13)+
' on a.memberuid = b.uid join '+@dbName +'.dbo.sysusers c
on a.groupuid = c.uid )s
Group by USERName
order by UserName'
--Print @mSql1
Execute (@mSql1)
FETCH NEXT FROM DBName_Cursor INTO @dbname
END
CLOSE DBName_Cursor
DEALLOCATE DBName_Cursor
Select * from #DBRoles
where ((@database is null) OR (DBName LIKE '%'+@database+'%')) AND
((@user is null) OR (UserName LIKE '%'+@user+'%')) AND
((@dbo is null) OR (db_owner = 'Yes')) AND
((@access is null) OR (db_accessadmin = 'Yes')) AND
((@security is null) OR (db_securityadmin = 'Yes')) AND
((@ddl is null) OR (db_ddladmin = 'Yes')) AND
((@datareader is null) OR (db_datareader = 'Yes')) AND
((@datawriter is null) OR (db_datawriter = 'Yes')) AND
((@denyread is null) OR (db_denydatareader = 'Yes')) AND
((@denywrite is null) OR (db_denydatawriter = 'Yes'))
Sunday, August 14, 2011
Sunday, August 7, 2011
Force client to update from WSUS
Get the client installed updates:
wmic qfe list > c:\Windowsupdate.txt
test Mail using telnet
EHLO DUCTEST.COM
RCPT TO: asabry@MYdOMAIN.cOM
DATA
This is a test message you will not see a response from this command.
QUIT