Simple and useful tool for creating timestamps in command line (batch). It need not fixed time format and is used current time zone.
Examples
for /f "tokens=1" %%a in ('timestamp.exe') do (
set timestamp=%%a
)
systeminfo > %timestamp%_%computername%.log
for /f "tokens=1-8 delims=- " %%a in ('timestamp.exe -d') do (
set year=%%a
set month=%%b
set day=%%c
set hour=%%d
set minute=%%e
set second=%%f
)
echo Now is %hour%:%minute%:%second% %month%-%day%-%year%
Download: timestamp.zip
Občas se hodí, když se něco musí spustit jen v konkrétní den týdne, např. v pátek:
řešení v batch
for /f "tokens=1 delims= " %%a in ('date/t') do set day=%%a
if /i %day% equ Fri (echo je patek, tak to spustim) else (echo neni patek)
řešení batch + powershell
for /f "tokens=1" %%i in ('powershell -command "&{[int](Get-Date).DayOfWeek}"') do set denTydne=%%i
if /i %denTydne% equ 5 (echo je patek, tak to spustim) else (echo neni patek)
řešení powershell
$denTydne = (Get-Date).DayOfWeek
if ($denTydne -ne 5) {"neni patek"} else {"je patek, tak to spustim"}
pozn. pokud bude OS lokalizovaný v ČJ je potřeba uložit skript v kódování Latin II (CP852), aby bylo zobrazení diakritiky správně interpretováno (např. Pátek)
Display all groups which is „Domain Users“ group member
dsquery group -name "domain users" | dsget group -memberof -expand | dsget group -samid
Display attribute rIDAvailablePool, this attribute specifies the space from which RID pools are allocated.
dsquery * "cn=rid manager$,cn=system,dc=domain,dc=com" -attr ridAvailablePool
Display list of users not logged since 1.11.2010
dsquery * "ou=users,dc=domain,dc=com" -filter "(&(objectCategory=user)(lastLogonTimestamp<=129330396000000000))" | dsget user -samid
Search a computer on the network by description - useful if description contain full user name
dsquery computer -desc *smith* | dsget computer -samid -desc
List groups a user is a member of
dsquery user -samid *userlogin* |dsget user -memberof -expand
dsquery user -samid *userlogin* |dsget user -memberof -expand |dsget group -samid
This command return the user accounts where is "Hide from Exchange address lists" parameter FALSE
dsquery * "ou=users,dc=myDomain,dc=cz" -limit 1000 -attr distinguishedName showInAddressBook | findstr /i "global"
Display all users atributes
dsquery * "ou=users,dc=myDomain,dc=cz" -attr *